Mercurial > hg > Members > Moririn
diff src/test/twice.cc @ 314:1839586f5b41
pthread CUDA test
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 15 Feb 2017 12:34:19 +0900 |
parents | 609bf62768b9 |
children |
line wrap: on
line diff
--- a/src/test/twice.cc Wed Feb 15 11:36:10 2017 +0900 +++ b/src/test/twice.cc Wed Feb 15 12:34:19 2017 +0900 @@ -2,6 +2,9 @@ #include <sys/time.h> #include <string.h> #include <stdlib.h> +extern "C" { +#include <pthread.h> +} #include <cuda.h> @@ -35,9 +38,12 @@ } } +int num_stream = 1; // number of stream +int num_exec = 16; // number of executed kernel + +static void *start_cuda(void *) ; + int main(int args, char* argv[]) { - int num_stream = 1; // number of stream - int num_exec = 16; // number of executed kernel for (int i=1;argv[i];i++) { if (strcmp(argv[i], "--stream") == 0 || strcmp(argv[i], "-s") == 0) { @@ -47,7 +53,17 @@ num_exec = atoi(argv[++i]); } } +#if 0 + start_cuda(NULL); +#else + pthread_t thread; + pthread_create(&thread, NULL, start_cuda, NULL); + pthread_join(thread,NULL); +#endif + return 0; +} +static void *start_cuda(void *args) { // initialize and load kernel CUdevice device; CUcontext context; @@ -161,7 +177,6 @@ for (int i=0;i<num_exec;i++) delete[] result[i]; delete[] result; - return 0; }