MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / exec

Method exec

src/jit/impl/nvrtc/compiler_cuda.cpp:214–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214void CudaExecutable::FuncCache::exec(
215 const JITExecutor* fusion_opr, const CudaExecutable* cuda_exe) {
216 Func* func;
217 {
218 MGB_LOCK_GUARD(mtx);
219 auto ins = cn2func.insert({fusion_opr->comp_node(), {}});
220 func = &ins.first->second;
221 if (ins.second) {
222 MGB_CUDA_CU_CHECK(cuModuleLoadData(&func->module, ptx.data()));
223 MGB_CUDA_CU_CHECK(cuModuleGetFunction(
224 &func->func, func->module, cuda_exe->m_name.c_str()));
225 int min_grid_size = 0;
226 MGB_CUDA_CU_CHECK(cuOccupancyMaxPotentialBlockSize(
227 &min_grid_size, &func->block_size, func->func, nullptr, 0, 0));
228 }
229 }
230
231#pragma GCC diagnostic push
232#pragma GCC diagnostic ignored "-Wunused-value"
233 int out_dim = fusion_opr->args().outputs[0].layout.ndim;
234#define cb_outdim(EXPECTED_OUTDIM) \
235 if (EXPECTED_OUTDIM == out_dim) { \
236 setup_and_launch<EXPECTED_OUTDIM>(fusion_opr, func->func, func->block_size); \
237 return; \
238 }
239#pragma GCC diagnostic push
240 cb_outdim(1);
241 cb_outdim(2);
242 cb_outdim(3);
243 cb_outdim(4);
244 mgb_throw(InternalError, "unsupported out_dim=%zu", static_cast<size_t>(out_dim));
245#undef cb_outdim
246}
247
248CudaExecutable::~CudaExecutable() {
249 for (auto&& i : m_func_cache) {

Callers 1

executeMethod · 0.45

Calls 4

argsMethod · 0.80
insertMethod · 0.45
comp_nodeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected