changeset 98:d400948dbbab

add Cuda infomation to context
author ikkun
date Mon, 01 Feb 2016 18:03:43 +0900
parents 485ea0290fae
children ca55f4be5f0f
files src/CMakeLists.txt src/parallel_execution/CMakeLists.txt src/parallel_execution/context.h src/parallel_execution/worker.c
diffstat 4 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/CMakeLists.txt	Fri Jan 29 05:40:04 2016 +0900
+++ b/src/CMakeLists.txt	Mon Feb 01 18:03:43 2016 +0900
@@ -10,7 +10,7 @@
 add_definitions("-Wall -g -O0")
 
 include_directories(include)
-
+include_directories($ENV{CUDA_PATH})
 add_subdirectory(allocate)
 add_subdirectory(list)
 add_subdirectory(llrb)
--- a/src/parallel_execution/CMakeLists.txt	Fri Jan 29 05:40:04 2016 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Mon Feb 01 18:03:43 2016 +0900
@@ -2,7 +2,7 @@
 
 add_definitions("-Wall -g -O0")
 
-set(CMAKE_C_COMPILER $ENV{CbC_Clang}/clang)
+set(CMAKE_C_COMPILER cbc-clang)
 
 add_executable(twice
                main.c
--- a/src/parallel_execution/context.h	Fri Jan 29 05:40:04 2016 +0900
+++ b/src/parallel_execution/context.h	Mon Feb 01 18:03:43 2016 +0900
@@ -1,5 +1,6 @@
 /* Context definition for llrb example */
 #include <pthread.h>
+#include <cuda.h>
 #include "stack.h"
 
 #define ALLOCATE_SIZE 20000000
@@ -106,6 +107,13 @@
         int num;
         struct Context* contexts;
     } worker;
+    struct CudaTask {
+        CUdevice device;
+        CUcontext cuCtx;
+        CUfunction code;
+        CUdeviceptr* deviceptr;
+        CUstream stream;
+    } cudatask;
     struct Task {
         enum Code code;
         int key;
--- a/src/parallel_execution/worker.c	Fri Jan 29 05:40:04 2016 +0900
+++ b/src/parallel_execution/worker.c	Mon Feb 01 18:03:43 2016 +0900
@@ -27,3 +27,8 @@
 __code getQueue_stub(struct Context* context) {
     goto getQueue(context, &context->data[ActiveQueue]->queue, &context->data[Node]->node);
 }
+__code twiceGpu(struct Context* context) {
+    cuMemcpyHtoDAsync(context,context,context,context->stream);
+    cuLaunchkanel();
+    cuMemcpyDtoHAsync();
+}