File: ut_chunking.c

package info (click to toggle)
netcdf-parallel 1%3A4.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 113,164 kB
  • sloc: ansic: 267,893; sh: 12,869; cpp: 5,822; yacc: 2,613; makefile: 1,813; lex: 1,216; xml: 173; awk: 2
file content (93 lines) | stat: -rwxr-xr-x 2,150 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 *	Copyright 2018, University Corporation for Atmospheric Research
 *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
 */

#include "ut_includes.h"

void ut_chunk_print(int sort, ...);

/**
Test computation of applying a slice to a sequence of chunks
*/

int
main(int argc, char** argv)
{
    int stat = NC_NOERR;
    NCZSliceProjections slpv[NC_MAX_VAR_DIMS];
    NCZOdometer* odom = NULL;
    Vardef* var = NULL;
    struct Common common;
    
    /* Initialize */
    memset(&slpv,0,sizeof(slpv));

    if((stat = ut_init(argc, argv, &utoptions))) goto done;

    var = nclistget(utoptions.vardefs,0);

    /* Fill in parts of common */
    fillcommon(&common,var);

    /* Set the printer */
    zutester.tests = UTEST_RANGE;
    zutester.print = ut_chunk_print;
    zutest = &zutester;

    if((stat = NCZ_projectslices(var->dimsizes, var->chunksizes, utoptions.slices, &common, &odom)))
	goto done;

#if 0
    {
	int i;
	size64_t* mem = (size64_t*)printer.output;
	for(i=0;i<printer.used;i++) {
	    printf("[%d] %llu\n",i,mem[i]);
	}
    }
#endif

done:
    ut_final();
    if(stat)
	nc_strerror(stat);
    return (stat ? 1 : 0);    
}

void
ut_chunk_print(int sort, ...)
{
    int i;
    va_list ap;    
#if 0
    struct Common* common = NULL;    
#endif
    size64_t rank; /* variable rank */
    NCZSlice* slices = NULL; /* the complete set of slices |slices| == R*/
    size64_t* chunksizes = NULL; /* the chunk length corresponding to the dimensions */
    NCZChunkRange* ranges = NULL; /* computed chunk ranges */

    va_start(ap,sort);
    
    switch (sort) {
    default: break; /* ignore */
    case UTEST_RANGE: /* () */
	rank = va_arg(ap,size64_t);
        slices = va_arg(ap,NCZSlice*);
	chunksizes = va_arg(ap,size64_t*);
        ranges = va_arg(ap,NCZChunkRange*);
        printf("Chunksizes: %s\n",nczprint_vector(rank,chunksizes));
        printf("Slices: ");
	for(i=0;i<rank;i++)
	    printf(" %s",nczprint_slicesx(rank,slices,1));
	printf("\n");
        printf("Ranges: ");
	for(i=0;i<rank;i++)
	    printf(" %s",nczprint_chunkrange(ranges[i]));
	printf("\n");
	break;
    }
    va_end(ap);
}