MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / create_module

Method create_module

deps/GraphBLAS/CUDA/jitify.hpp:1125–1200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1123 }
1124 }
1125 inline void create_module(std::vector<std::string> link_files,
1126 std::vector<std::string> link_paths) {
1127 CUresult result;
1128#ifndef JITIFY_PRINT_LINKER_LOG
1129 // WAR since linker log does not seem to be constructed using a single call
1130 // to cuModuleLoadDataEx.
1131 if (link_files.empty()) {
1132 result =
1133 cuModuleLoadDataEx(&_module, _ptx.c_str(), (unsigned)_opts.size(),
1134 _opts.data(), _optvals.data());
1135 } else
1136#endif
1137 {
1138 cuda_safe_call(cuLinkCreate((unsigned)_opts.size(), _opts.data(),
1139 _optvals.data(), &_link_state));
1140 cuda_safe_call(cuLinkAddData(_link_state, CU_JIT_INPUT_PTX,
1141 (void*)_ptx.c_str(), _ptx.size(),
1142 "jitified_source.ptx", 0, 0, 0));
1143 for (int i = 0; i < (int)link_files.size(); ++i) {
1144 std::string link_file = link_files[i];
1145 CUjitInputType jit_input_type;
1146 if (link_file == ".") {
1147 // Special case for linking to current executable.
1148 link_file = get_current_executable_path();
1149 jit_input_type = CU_JIT_INPUT_OBJECT;
1150 } else {
1151 // Infer based on filename.
1152 jit_input_type = get_cuda_jit_input_type(&link_file);
1153 }
1154 CUresult result = cuLinkAddFile(_link_state, jit_input_type,
1155 link_file.c_str(), 0, 0, 0);
1156 int path_num = 0;
1157 while (result == CUDA_ERROR_FILE_NOT_FOUND &&
1158 path_num < (int)link_paths.size()) {
1159 std::string filename = path_join(link_paths[path_num++], link_file);
1160 result = cuLinkAddFile(_link_state, jit_input_type, filename.c_str(),
1161 0, 0, 0);
1162 }
1163#if JITIFY_PRINT_LINKER_LOG
1164 if (result == CUDA_ERROR_FILE_NOT_FOUND) {
1165 std::cerr << "Linker error: Device library not found: " << link_file
1166 << std::endl;
1167 } else if (result != CUDA_SUCCESS) {
1168 std::cerr << "Linker error: Failed to add file: " << link_file
1169 << std::endl;
1170 std::cerr << _error_log << std::endl;
1171 }
1172#endif
1173 cuda_safe_call(result);
1174 }
1175 size_t cubin_size;
1176 void* cubin;
1177 result = cuLinkComplete(_link_state, &cubin, &cubin_size);
1178 if (result == CUDA_SUCCESS) {
1179 result = cuModuleLoadData(&_module, cubin);
1180 }
1181 }
1182#ifdef JITIFY_PRINT_LINKER_LOG

Callers 2

CUDAKernelMethod · 0.95
CUDAKernelClass · 0.95

Calls 4

get_cuda_jit_input_typeFunction · 0.85
path_joinFunction · 0.85
demangle_cuda_symbolFunction · 0.85

Tested by

no test coverage detected