CUresult cuStatus;
string module_path;
string ptx_source;
char *actual_path = new char[strlen(exec_path) + 1];
strcpy(actual_path, exec_path);
strcat(actual_path, "\\");
strcat(actual_path, filename);
printf("actual_path=%s\n", actual_path);
if (actual_path != NULL)
{
module_path = actual_path;
}
else
{
printf(">> modInitCTX() <%36s> not found!\n", pCtx->mModuleName.c_str());
return false;
}
if (module_path.empty())
{
printf(">> modInitCTX() <%s> not found!\n", pCtx->mModuleName.c_str());
return false;
}
else
{
FILE *fp = fopen(module_path.c_str(), "rb");
fseek(fp, 0, SEEK_END);
int file_size = ftell(fp);
char *buf = new char[file_size+1];
fseek(fp, 0, SEEK_SET);
fread(buf, sizeof(char), file_size, fp);
fclose(fp);
buf[file_size] = '\0';
ptx_source = buf;
delete [] buf;
}
if (pCtx->mModuleName.rfind(".ptx") != string::npos)
{
// in this branch we use compilation with parameters
const unsigned int jitNumOptions = 3;
CUjit_option *jitOptions = new CUjit_option[jitNumOptions];
void **jitOptVals = new void *[jitNumOptions];
// set up size of compilation log buffer
jitOptions[0] = CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES;
int jitLogBufferSize = 1024;
jitOptVals[0] = (void *)(size_t)jitLogBufferSize;
// set up pointer to the compilation log buffer
jitOptions[1] = CU_JIT_INFO_LOG_BUFFER;
char *jitLogBuffer = new char[jitLogBufferSize];
jitOptVals[1] = jitLogBuffer;
// set up pointer to set the Maximum # of registers for a particular kernel
jitOptions[2] = CU_JIT_MAX_REGISTERS;
int jitRegCount = 32;
jitOptVals[2] = (void *)(size_t)jitRegCount;
[b] cuStatus = cuModuleLoadDataEx(&pCtx->cuModule_, ptx_source.c_str(), jitNumOptions, jitOptions, (void **)jitOptVals);[/b]
if (cuStatus != CUDA_SUCCESS)
{
printf("cuModuleLoadDataEx error!\n");
}
// printf("> PTX JIT log:\n%s\n", jitLogBuffer);
delete[] jitOptions;
delete[] jitOptVals;
delete[] jitLogBuffer;
}
else
{
cuStatus = cuModuleLoad(&pCtx->cuModule_, module_path.c_str());
if (cuStatus != CUDA_SUCCESS)
{
printf("cuModuleLoad error!\n");
}
}
printf(">> modInitCTX<%s> initialized %s",
pCtx->mModuleName.c_str(), (cuStatus == CUDA_SUCCESS) ? "SUCCESS!\n" : "FAILED\n");
The win10 Qudro P2000 is passable and the win10 Qudro P400 or win10 Qudro P620 are not available.
Always report errors in illegal pointer references to memory
Tracking debugging, these variables are valuable, once to that cuModuleLoadDataEx function error.