diff TaskManager/Cuda/CudaError.h @ 1908:bd5152f8fe3a draft

cuda
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Fri, 17 Jan 2014 10:21:08 +0900
parents
children cd5bbd8ec5d6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Cuda/CudaError.h	Fri Jan 17 10:21:08 2014 +0900
@@ -0,0 +1,45 @@
+// enum to string
+// これ自分で書くのあれだよね
+const char* convert_error_status(unsigned int status){ 
+    static const struct {
+        const unsigned int status;
+        const char* status_string;
+    } Error_Status[] = {
+        {cudaSuccess,                       "cudaSuccess"},
+        {cudaErrorMissingConfiguration,     "cudaErrorMissingConfiguration"},
+        {cudaErrorMemoryAllocation,         "cudaErrorMemoryAllocation"},
+        {cudaErrorInitializationError,      "cudaErrorInitializationError"},
+        {cudaErrorLaunchFailure,            "cudaErrorLaunchFailure"},
+        {cudaErrorLaunchTimeout,            "cudaErrorLaunchTimeout"},
+        {cudaErrorLaunchOutOfResources,     "cudaErrorLaunchOutOfResources"},
+        {cudaErrorInvalidDeviceFunction,    "cudaErrorInvalidDeviceFunction"},
+        {cudaErrorInvalidConfiguration,     "cudaErrorInvalidConfiguration"},
+        {cudaErrorInvalidDevice,            "cudaErrorInvalidDevice"},
+        {cudaErrorInvalidValue,             "cudaErrorInvalidValue"},
+        {cudaErrorInvalidPitchValue,        "cudaErrorInvalidPitchValue"},
+        {cudaErrorInvalidSymbol,            "cudaErrorInvalidSymbol"},
+        {cudaErrorUnmapBufferObjectFailed,  "cudaErrorUnmapBufferObjectFailed"},
+        {cudaErrorInvalidHostPointer,       "cudaErrorInvalidHostPointer"},
+        {cudaErrorInvalidDevicePointer,     "cudaErrorInvalidDevicePointer"},
+        {cudaErrorInvalidTexture,           "cudaErrorInvalidTexture"},
+        {cudaErrorInvalidTextureBinding,    "cudaErrorInvalidTextureBinding"},
+        {cudaErrorInvalidChannelDescriptor, "cudaErrorInvalidChannelDescriptor"},
+        {cudaErrorInvalidMemcpyDirection,   "cudaErrorInvalidMemcpyDirection"},
+        {cudaErrorInvalidFilterSetting,     "cudaErrorInvalidFilterSetting"},
+        {cudaErrorInvalidNormSetting,       "cudaErrorInvalidNormSetting"},
+        {cudaErrorUnknown,                  "cudaErrorUnknown"},
+        {cudaErrorInvalidResourceHandle,    "cudaErrorInvalidResourceHandle"},
+        {cudaErrorInsufficientDriver,       "cudaErrorInsufficientDriver"},
+        {cudaErrorSetOnActiveProcess,       "cudaErrorSetOnActiveProcess"},
+        {cudaErrorStartupFailure,           "cudaErrorStartupFailure"},
+        {0, NULL}
+    };
+    const char* message;
+
+    for(int i=0; Error_Status[i].status_string != NULL; i++) {
+        if (Error_Status[i].status = status) {
+            message = Error_Status[i].status_string;
+        }
+    }
+    return message;
+}