File: simple_test.c

package info (click to toggle)
mpich 4.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,184 kB
  • sloc: ansic: 1,040,629; cpp: 82,270; javascript: 40,763; perl: 27,933; python: 16,041; sh: 14,676; xml: 14,418; f90: 12,916; makefile: 9,270; fortran: 8,046; java: 4,635; asm: 324; ruby: 103; awk: 27; lisp: 19; php: 8; sed: 4
file content (81 lines) | stat: -rw-r--r-- 2,108 bytes parent folder | download | duplicates (3)
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
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

#include <stdio.h>
#include "yaksa.h"
#include <assert.h>

#define DIMSIZE (80)

int inbuf[DIMSIZE * DIMSIZE], outbuf[DIMSIZE * DIMSIZE];

int main()
{
    int rc = YAKSA_SUCCESS;
    yaksa_type_t vector, vector_vector;
    uintptr_t actual;

    yaksa_init(NULL);

    rc = yaksa_type_create_vector(3, 2, 3, YAKSA_TYPE__INT, NULL, &vector);
    assert(rc == YAKSA_SUCCESS);

    rc = yaksa_type_create_vector(5, 1, 10, vector, NULL, &vector_vector);
    assert(rc == YAKSA_SUCCESS);

    for (int i = 0; i < DIMSIZE * DIMSIZE; i++) {
        inbuf[i] = i;
        outbuf[i] = -1;
    }

    yaksa_request_t request;
    rc = yaksa_ipack(inbuf, 1, vector_vector, 0, outbuf, DIMSIZE * DIMSIZE * sizeof(int), &actual,
                     NULL, YAKSA_OP__REPLACE, &request);
    assert(rc == YAKSA_SUCCESS);
    assert(actual == 5 * 3 * 2 * sizeof(int));

    rc = yaksa_request_wait(request);
    assert(rc == YAKSA_SUCCESS);

    int idx = 0;
    int val = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 2; k++) {
                inbuf[val] = -1;
                if (outbuf[idx] != val)
                    fprintf(stderr, "outbuf[%d] = %d instead of %d\n", idx, outbuf[idx], val);
                idx++;
                val++;
            }
            val++;
        }
        val += 71;
    }

    uintptr_t actual_unpack_bytes;
    rc = yaksa_iunpack(outbuf, actual, inbuf, 1, vector_vector, 0, &actual_unpack_bytes,
                       NULL, YAKSA_OP__REPLACE, &request);
    assert(rc == YAKSA_SUCCESS);

    rc = yaksa_request_wait(request);
    assert(rc == YAKSA_SUCCESS);

    idx = 0;
    for (int i = 0; i < DIMSIZE; i++) {
        for (int j = 0; j < DIMSIZE; j++) {
            if (inbuf[idx] != idx)
                fprintf(stderr, "inbuf[%d] = %d instead of %d\n", idx, inbuf[idx], idx);
            idx++;
        }
    }

    yaksa_type_free(vector_vector);
    yaksa_type_free(vector);

    yaksa_finalize();

    return 0;
}