11#include "nomp-test.h"
22
3+ #define nomp_api_200_aux_ui TOKEN_PASTE(nomp_api_200_aux_ui, TEST_SUFFIX)
4+ static int nomp_api_200_aux_ui (const char * fmt , TEST_TYPE * a , TEST_TYPE * b ,
5+ unsigned n ) {
6+ nomp_test_chk (nomp_update (a , 0 , n , sizeof (TEST_TYPE ), NOMP_TO ));
7+ nomp_test_chk (nomp_update (b , 0 , n , sizeof (TEST_TYPE ), NOMP_TO ));
8+
9+ int id = -1 ;
10+ const char * clauses [4 ] = {"transform" , "nomp-api-200" , "transform" , 0 };
11+ char * knl = generate_knl (fmt , 2 , TOSTRING (TEST_TYPE ), TOSTRING (TEST_TYPE ));
12+ nomp_test_chk (nomp_jit (& id , knl , clauses , 3 , "a" , sizeof (TEST_TYPE ), NOMP_PTR ,
13+ "b" , sizeof (TEST_TYPE ), NOMP_PTR , "N" ,
14+ sizeof (unsigned ), NOMP_UINT ));
15+ nomp_free (& knl );
16+
17+ nomp_test_chk (nomp_run (id , a , b , & n ));
18+
19+ nomp_test_chk (nomp_sync ());
20+
21+ nomp_test_chk (nomp_update (a , 0 , n , sizeof (TEST_TYPE ), NOMP_FROM ));
22+ nomp_test_chk (nomp_update (a , 0 , n , sizeof (TEST_TYPE ), NOMP_FREE ));
23+ nomp_test_chk (nomp_update (b , 0 , n , sizeof (TEST_TYPE ), NOMP_FREE ));
24+
25+ return 0 ;
26+ }
27+
28+ #define nomp_api_200_add_ui TOKEN_PASTE(nomp_api_200_add_ui, TEST_SUFFIX)
29+ static int nomp_api_200_add_ui (unsigned n ) {
30+ nomp_test_assert (n <= TEST_MAX_SIZE );
31+
32+ TEST_TYPE a [TEST_MAX_SIZE ], b [TEST_MAX_SIZE ];
33+ for (unsigned i = 0 ; i < n ; i ++ )
34+ a [i ] = n - i , b [i ] = i ;
35+
36+ const char * knl_fmt =
37+ "void foo(%s *a, %s *b, int N) { \n"
38+ " for (int i = 0; i < N; i++) \n"
39+ " a[i] += b[i]; \n"
40+ "} \n" ;
41+ nomp_api_200_aux_ui (knl_fmt , a , b , n );
42+
43+ #if defined(TEST_TOL )
44+ for (unsigned i = 0 ; i < n ; i ++ )
45+ nomp_test_assert (fabs (a [i ] - n ) < TEST_TOL );
46+ #else
47+ for (unsigned i = 0 ; i < n ; i ++ )
48+ nomp_test_assert (a [i ] == (TEST_TYPE )n );
49+ #endif
50+
51+ return 0 ;
52+ }
53+ #undef nomp_api_200_add_ui
54+ #undef nomp_api_200_aux_ui
55+
356#define nomp_api_200_aux TOKEN_PASTE(nomp_api_200_aux, TEST_SUFFIX)
457static int nomp_api_200_aux (const char * fmt , TEST_TYPE * a , TEST_TYPE * b ,
558 int n ) {
@@ -161,8 +214,8 @@ static int nomp_api_200_square(unsigned n) {
161214}
162215#undef nomp_api_200_square
163216
164- #define nomp_api_200_linear TOKEN_PASTE(nomp_api_200_linear , TEST_SUFFIX)
165- static int nomp_api_200_linear (unsigned n ) {
217+ #define nomp_api_200_assign TOKEN_PASTE(nomp_api_200_assign , TEST_SUFFIX)
218+ static int nomp_api_200_assign (unsigned n ) {
166219 nomp_test_assert (n <= TEST_MAX_SIZE );
167220
168221 TEST_TYPE a [TEST_MAX_SIZE ] = {0 }, b [TEST_MAX_SIZE ] = {1 , 2 , 3 , 4 , 5 };
@@ -184,5 +237,5 @@ static int nomp_api_200_linear(unsigned n) {
184237
185238 return 0 ;
186239}
187- #undef nomp_api_200_linear
240+ #undef nomp_api_200_assign
188241#undef nomp_api_200_aux
0 commit comments