|
| 1 | +/* |
| 2 | + * Copyright (C) by Argonne National Laboratory |
| 3 | + * See COPYRIGHT in top-level directory |
| 4 | + */ |
| 5 | + |
| 6 | +#include <stdio.h> |
| 7 | +#include "yaksa.h" |
| 8 | +#include <assert.h> |
| 9 | + |
| 10 | +#define DIMSIZE (80) |
| 11 | + |
| 12 | +int inbuf[DIMSIZE * DIMSIZE], outbuf[DIMSIZE * DIMSIZE]; |
| 13 | + |
| 14 | +int main() |
| 15 | +{ |
| 16 | + int rc = YAKSA_SUCCESS; |
| 17 | + yaksa_type_t vector, vector_vector; |
| 18 | + uintptr_t actual; |
| 19 | + |
| 20 | + yaksa_init(NULL); |
| 21 | + int idx = 0; |
| 22 | + |
| 23 | + for (int i = 0; i < DIMSIZE * DIMSIZE; i++) { |
| 24 | + inbuf[i] = i; |
| 25 | + outbuf[i] = -1; |
| 26 | + } |
| 27 | + |
| 28 | + rc = yaksa_type_create_vector(3, 2, 3, YAKSA_TYPE__INT, NULL, &vector); |
| 29 | + assert(rc == YAKSA_SUCCESS); |
| 30 | + |
| 31 | + yaksa_request_t request; |
| 32 | + rc = yaksa_ipack(inbuf, 1, vector, 0, outbuf, DIMSIZE * DIMSIZE * sizeof(int), &actual, |
| 33 | + NULL, &request); |
| 34 | + assert(rc == YAKSA_SUCCESS); |
| 35 | + |
| 36 | + /* Here inbuf is the dest buffer that contains strided datai, outbuf contains packed data */ |
| 37 | + rc = yaksa_iacc(outbuf, actual, inbuf, 1, vector, 0, YAKSA_OP__SUM, |
| 38 | + NULL, &request); |
| 39 | + assert(rc == YAKSA_SUCCESS); |
| 40 | + |
| 41 | + rc = yaksa_request_wait(request); |
| 42 | + assert(rc == YAKSA_SUCCESS); |
| 43 | + |
| 44 | + idx = 0; |
| 45 | + for (int i = 0; i < 3*2; i++) { |
| 46 | + if (i == 2 || i ==5) |
| 47 | + continue; |
| 48 | + if (inbuf[i] != i*2) |
| 49 | + fprintf(stderr, "Error at i = %d\n", i); |
| 50 | + } |
| 51 | + |
| 52 | + yaksa_type_free(vector_vector); |
| 53 | + yaksa_type_free(vector); |
| 54 | + |
| 55 | + yaksa_finalize(); |
| 56 | + |
| 57 | + return 0; |
| 58 | +} |
0 commit comments