From dfeb15d03b25b789df9565f5c70bfb3250b6c4bd Mon Sep 17 00:00:00 2001 From: Davide Rossetti Date: Tue, 20 Jun 2017 14:49:55 -0700 Subject: [PATCH] introduce -w (use_wrmem) to enable use of WRITE_MEMORY. add GDSCHECK to API calls. --- tests/gds_poll_lat.c | 119 +++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 60 deletions(-) diff --git a/tests/gds_poll_lat.c b/tests/gds_poll_lat.c index 01a0aca..d7e0da5 100644 --- a/tests/gds_poll_lat.c +++ b/tests/gds_poll_lat.c @@ -35,6 +35,7 @@ int main(int argc, char *argv[]) int use_flush = 0; int use_combined = 0; int use_membar = 0; + int use_wrmem = 0; int wait_key = -1; CUstream gpu_stream; @@ -44,7 +45,7 @@ int main(int argc, char *argv[]) while(1) { int c; - c = getopt(argc, argv, "cd:p:n:s:hfgP:mW:"); + c = getopt(argc, argv, "cd:p:n:s:hfgP:mW:w"); if (c == -1) break; @@ -77,22 +78,32 @@ int main(int argc, char *argv[]) break; case 'f': use_flush = 1; - printf("INFO enabling flush\n"); + gpu_info("enabling flush\n"); break; case 'g': use_gpu_buf = 1; - printf("INFO polling on GPU buffer\n"); + gpu_info("polling on GPU buffer\n"); break; + case 'w': + use_wrmem = 1; + gpu_info("enabling use of WRITE_MEMORY\n"); + break; + case '?': case 'h': printf(" %s [-n ][-s ][-p # bg streams][-P # pokes][ckhfgomW]\n", argv[0]); exit(EXIT_SUCCESS); break; default: - printf("ERROR: invalid option\n"); + gpu_err("invalid option '%c'\n", c); exit(EXIT_FAILURE); } } + if (n_pokes < 1) { + gpu_err("n_pokes must be 1 at least\n"); + exit(EXIT_FAILURE); + } + CUstream bg_streams[n_bg_streams]; memset(bg_streams, 0, sizeof(bg_streams)); @@ -103,28 +114,26 @@ int main(int argc, char *argv[]) const char *tags = "postpoll|que poke| sleep| set dw|pollpoke|str sync"; if ( /*prof_init(&prof, 1000, 1000, "1ms", 50, 1, tags)*/ prof_init(&prof, 100, 100, "100ns", 25*4*2, 5, tags)) { - fprintf(stderr, "error in prof_init init.\n"); + gpu_err("error in prof_init init.\n"); exit(EXIT_FAILURE); } if (gpu_init(gpu_id, CU_CTX_SCHED_AUTO)) { - fprintf(stderr, "error in GPU init.\n"); + gpu_err("error in GPU init.\n"); exit(EXIT_FAILURE); } CUCHECK(cuStreamCreate(&gpu_stream, 0)); - puts(""); - printf("number iterations %d\n", num_iters); - printf("num dwords per poke %zu\n", n_pokes); - printf("use poll flush %d\n", use_flush); - printf("use poke membar %d\n", use_membar); - printf("use %d background streams\n", n_bg_streams); - printf("sleep %dus\n", sleep_us); - printf("buffer size %zd\n", size); - printf("poll on %s buffer\n", use_gpu_buf?"GPU":"CPU"); - printf("write on %s buffer\n", use_gpu_buf?"GPU":"CPU"); - puts(""); + gpu_info("number iterations %d\n", num_iters); + gpu_info("num dwords per poke %zu\n", n_pokes); + gpu_info("use poll flush %d\n", use_flush); + gpu_info("use poke membar %d\n", use_membar); + gpu_info("use %d background streams\n", n_bg_streams); + gpu_info("sleep %dus\n", sleep_us); + gpu_info("buffer size %zd\n", size); + gpu_info("poll on %s buffer\n", use_gpu_buf?"GPU":"CPU"); + gpu_info("write on %s buffer\n", use_gpu_buf?"GPU":"CPU"); gds_mem_desc_t desc = {0,}; ret = gds_alloc_mapped_memory(&desc, size, use_gpu_buf?GDS_MEMORY_GPU:GDS_MEMORY_HOST); @@ -134,7 +143,7 @@ int main(int argc, char *argv[]) } CUdeviceptr d_buf = desc.d_ptr; void *h_buf = desc.h_ptr; - printf("allocated d_buf=%p h_buf=%p\n", (void*)d_buf, h_buf); + gpu_info("allocated d_buf=%p h_buf=%p\n", (void*)d_buf, h_buf); memset(h_buf, 0, size); gds_mem_desc_t desc_data = {0,}; @@ -145,7 +154,7 @@ int main(int argc, char *argv[]) } CUdeviceptr d_data = desc_data.d_ptr; uint32_t *h_data = desc_data.h_ptr; - printf("allocated d_data=%p h_data=%p\n", (void*)d_data, h_data); + gpu_info("allocated d_data=%p h_data=%p\n", (void*)d_data, h_data); memset(h_data, 0, size); int i; @@ -158,7 +167,7 @@ int main(int argc, char *argv[]) uint32_t *h_bg_buf = NULL; if (n_bg_streams) { - printf("launching background %dx poll\n", n_bg_streams); + gpu_info("launching background %dx poll\n", n_bg_streams); ASSERT(!posix_memalign((void*)&h_bg_buf, page_size, size)); memset(h_bg_buf, 0, size); for (i=0; i warmup) { double avg_wait_us = (double)delta_t / (double)(num_iters - warmup); - printf("average wait time: %fus\n", avg_wait_us); + printf("sleep time: %d average wait time: %fus\n", sleep_us, avg_wait_us); } perf_stop(); prof_dump(&prof); err: if (n_bg_streams) { - printf("signaling %d background polling stream(s)\n", n_bg_streams); + gpu_info("signaling %d background polling stream(s)\n", n_bg_streams); int s; for (s=0; s