fix test case to map an int instead of bool.  Also return 0 when setting of unmapped pointer in USM mode and 0 if pointer set to null in non USM mode, and 1 otherwise
#include <iostream>
+#ifdef REQUIRES_USM
#pragma omp requires unified_shared_memory
+#define IS_USM 1
+#else
+#define IS_USM 0
+#endif
int main() {
int *a = (int *) malloc(sizeof(int));
- bool is_set = false;
+ int is_set = 1;
+ printf("host a:%p \n", (void*) a);
// a is passed by-value to kernel with unified_shared_memory; set to nullptr without
// map of is_set should be respected
#pragma omp target map(tofrom: is_set)
{
- if (a != nullptr)
- is_set = true;
+ printf("device a:%p \n", (void*) a);
+ if (a == nullptr)
+ is_set = 0;
else
- is_set = false;
+ is_set = 1;
}
- if (!is_set)
- std::cout << "a not set\n";
+ if (is_set)
+ std::cout << "Pointer a is set. This should be USM mode\n";
+ else
+ std::cout << "Pointer a is NOT set. This should be default mode \n";
+ if (IS_USM && is_set)
+ return 0;
+ else if (!IS_USM && !is_set)
return 0;
+ else if (!IS_USM && is_set)
+ return 1;
+ else if (IS_USM && !is_set)
+ return 1;
}
