diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2012-07-11 19:56:19 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2012-07-11 19:56:19 +0000 |
commit | 714bcf260f8a180c877783c5d50f4865f16a7ec9 (patch) | |
tree | 179dfabb57cce979905b3bd9b4972565f201c5f0 | |
parent | 38995d80b4a57e3ee8aaed6c133d149d3028b863 (diff) |
use-host-ptr: Change into a test
-rw-r--r-- | use_host_ptr.c | 23 |
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; + } } |