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;
}
|