MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / findModulePath

Function findModulePath

cpp/3_CUDA_Features/memMapIPCDrv/memMapIpc.cpp:629–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627}
628
629bool inline findModulePath(const char *module_file, string &module_path, char **argv, string &ptx_source)
630{
631 char *actual_path = sdkFindFilePath(module_file, argv[0]);
632
633 if (actual_path) {
634 module_path = actual_path;
635 }
636 else {
637 printf("> findModulePath file not found: <%s> \n", module_file);
638 return false;
639 }
640
641 if (module_path.empty()) {
642 printf("> findModulePath could not find file: <%s> \n", module_file);
643 return false;
644 }
645 else {
646 printf("> findModulePath found file at <%s>\n", module_path.c_str());
647
648 if (module_path.rfind(".ptx") != string::npos) {
649 FILE *fp = fopen(module_path.c_str(), "rb");
650 fseek(fp, 0, SEEK_END);
651 int file_size = ftell(fp);
652 char *buf = new char[file_size + 1];
653 fseek(fp, 0, SEEK_SET);
654 fread(buf, sizeof(char), file_size, fp);
655 fclose(fp);
656 buf[file_size] = '\0';
657 ptx_source = buf;
658 delete[] buf;
659 }
660
661 return true;
662 }
663}

Callers 1

memMapGetDeviceFunctionFunction · 0.70

Calls 2

sdkFindFilePathFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected