Skip to content

Commit cef01ba

Browse files
author
nislam
committed
test: Add a test for SUM operation
1 parent 1c6724f commit cef01ba

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

test/simple/Makefile.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ EXTRA_DIST += $(top_srcdir)/test/simple/testlist.gen
88

99
EXTRA_PROGRAMS += \
1010
test/simple/simple_test \
11+
test/simple/simple_test1 \
1112
test/simple/threaded_test
1213

1314
test_simple_simple_test_CPPFLAGS = $(test_cppflags)
1415
test_simple_threaded_test_CPPFLAGS = $(test_cppflags)
16+
test_simple_simple_test1_CPPFLAGS = $(test_cppflags)
1517

1618
test-simple:
1719
@$(top_srcdir)/test/runtests.py --summary=$(top_builddir)/test/simple/summary.junit.xml \

test/simple/simple_test1.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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

Comments
 (0)