view TaskManager/Cuda/CudaError.h @ 1910:b7b528e9ec5e draft

Implement divide read in word_count ( but cannot running )
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Sun, 19 Jan 2014 22:54:01 +0900
parents bd5152f8fe3a
children cd5bbd8ec5d6
line wrap: on
line source

// 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;
}