view TaskManager/Cuda/CudaError.h @ 2022:fac44ad2867d draft

make a sound
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Wed, 16 Jul 2014 02:50:32 +0900
parents 67e50779feb4
children
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[] = {
        {CUDA_SUCCESS,                              "CUDA_SUCCESS"},
        {CUDA_ERROR_INVALID_VALUE,                  "CUDA_ERROR_INVALID_VALUE"},
        {CUDA_ERROR_OUT_OF_MEMORY,                  "CUDA_ERROR_OUT_OF_MEMORY"},
        {CUDA_ERROR_NOT_INITIALIZED,                "CUDA_ERROR_NOT_INITIALIZED"},
        {CUDA_ERROR_DEINITIALIZED,                  "CUDA_ERROR_DEINITIALIZED"},
        {CUDA_ERROR_NO_DEVICE,                      "CUDA_ERROR_NO_DEVICE"},
        {CUDA_ERROR_INVALID_DEVICE,                 "CUDA_ERROR_INVALID_DEVICE"},
        {CUDA_ERROR_INVALID_IMAGE,                  "CUDA_ERROR_INVALID_IMAGE"},
        {CUDA_ERROR_INVALID_CONTEXT,                "CUDA_ERROR_INVALID_CONTEXT"},
        {CUDA_ERROR_CONTEXT_ALREADY_CURRENT,        "CUDA_ERROR_CONTEXT_ALREADY_CURRENT"},
        {CUDA_ERROR_MAP_FAILED,                     "CUDA_ERROR_MAP_FAILED"},
        {CUDA_ERROR_UNMAP_FAILED,                   "CUDA_ERROR_UNMAP_FAILED"},
        {CUDA_ERROR_ARRAY_IS_MAPPED,                "CUDA_ERROR_ARRAY_IS_MAPPED"},
        {CUDA_ERROR_ALREADY_MAPPED,                 "CUDA_ERROR_ALREADY_MAPPED"},
        {CUDA_ERROR_NO_BINARY_FOR_GPU,              "CUDA_ERROR_NO_BINARY_FOR_GPU"},
        {CUDA_ERROR_ALREADY_ACQUIRED,               "CUDA_ERROR_ALREADY_ACQUIRED"},
        {CUDA_ERROR_NOT_MAPPED,                     "CUDA_ERROR_NOT_MAPPED"},
        {CUDA_ERROR_NOT_MAPPED_AS_ARRAY,            "CUDA_ERROR_NOT_MAPPED_AS_ARRAY"},
        {CUDA_ERROR_NOT_MAPPED_AS_POINTER,          "CUDA_ERROR_NOT_MAPPED_AS_POINTER"},
        {CUDA_ERROR_ECC_UNCORRECTABLE,              "CUDA_ERROR_ECC_UNCORRECTABLE"},
        {CUDA_ERROR_UNSUPPORTED_LIMIT,              "CUDA_ERROR_UNSUPPORTED_LIMIT"},
        {CUDA_ERROR_INVALID_SOURCE,                 "CUDA_ERROR_INVALID_SOURCE"},
        {CUDA_ERROR_FILE_NOT_FOUND,                 "CUDA_ERROR_FILE_NOT_FOUND"},
        {CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND, "CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"},
        {CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,      "CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"},
        {CUDA_ERROR_OPERATING_SYSTEM,               "CUDA_ERROR_OPERATING_SYSTEM"},
        {CUDA_ERROR_INVALID_HANDLE,                 "CUDA_ERROR_INVALID_HANDLE"},
        {CUDA_ERROR_NOT_FOUND,                      "CUDA_ERROR_NOT_FOUND"},
        {CUDA_ERROR_NOT_READY,                      "CUDA_ERROR_NOT_READY"},
        {CUDA_ERROR_LAUNCH_FAILED,                  "CUDA_ERROR_LAUNCH_FAILED"},
        {CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,        "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"},
        {CUDA_ERROR_LAUNCH_TIMEOUT,                 "CUDA_ERROR_LAUNCH_TIMEOUT"},
        {CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,  "CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING"},
        {CUDA_ERROR_UNKNOWN,                        "CUDA_ERROR_UNKNOWN"},
        {0, NULL}
    };
    const char* message = "UNKNOWN ERROR.";

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