summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--use_host_ptr.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/use_host_ptr.c b/use_host_ptr.c
index ad4d345..1a24e35 100644
--- a/use_host_ptr.c
+++ b/use_host_ptr.c
@@ -15,8 +15,10 @@ int main(int argc, char ** argv)
int * out;
int * new_out;
size_t global_work_size = 10;
+ unsigned prestore = 12345;
unsigned out_size;
int iterations, i, j;
+ unsigned pass = 1;
if (argc !=2 ) {
fprintf(stderr, "Usage: use-host-ptr iterations\n");
@@ -26,7 +28,7 @@ int main(int argc, char ** argv)
iterations = atoi(argv[1]);
out_size = (global_work_size * iterations + 1) * sizeof(int);
out = malloc(out_size);
- out[global_work_size * iterations] = 12345;
+ out[global_work_size * iterations] = prestore;
if (!clSimpleSimpleInit(&context, "loop_lt")) {
return EXIT_FAILURE;
@@ -80,10 +82,25 @@ int main(int argc, char ** argv)
for (i = 0; i < global_work_size; i++) {
for (j = 0; j < iterations; j++) {
unsigned id = (i * iterations) + j;
+ if (new_out[id] != id) {
+ fprintf(stderr, "Expected %u, but got %u\n", id, new_out[id]);
+ pass = 0;
+ }
fprintf(stderr, "%2d ", new_out[id]);
}
fprintf(stderr, "\n");
}
- fprintf(stderr, "Prestore = %d\n", out[global_work_size * iterations]);
- return EXIT_SUCCESS;
+ if (out[global_work_size * iterations] != prestore) {
+ fprintf(stderr, "Prestore expected %d, got %d\n", prestore,
+ out[global_work_size * iterations]);
+ pass = 0;
+ }
+
+ if (pass) {
+ fprintf(stderr, "Pass\n");
+ return EXIT_SUCCESS;
+ } else {
+ fprintf(stderr, "Fail\n");
+ return EXIT_FAILURE;
+ }
}