MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / CompileCudaModule

Method CompileCudaModule

paddle/cinn/backends/compiler.cc:673–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

671}
672
673void Compiler::CompileCudaModule(const Module& module,
674 const std::string& code) {
675#ifdef CINN_WITH_CUDA
676 auto _host_module_device_module_ =
677 SplitDeviceAndHostModule(module); // NOLINT
678 auto& host_module = std::get<0>(_host_module_device_module_);
679 auto& device_module = std::get<1>(_host_module_device_module_);
680 VLOG(3) << "[CUDA] host module:\n" << host_module;
681
682 VLOG(3) << "[CUDA] device module:\n" << device_module;
683 std::string source_code;
684
685 if (!FLAGS_cinn_debug_custom_code_path.empty()) {
686 std::string file_path = FLAGS_cinn_debug_custom_code_path;
687 source_code = GetFileContent(file_path);
688 } else if (code.empty()) {
689 CodeGenCudaDev codegen(target_);
690 source_code = codegen.Compile(device_module);
691 } else {
692 source_code = code;
693 }
694
695 PADDLE_ENFORCE_EQ(!source_code.empty(),
696 true,
697 ::common::errors::InvalidArgument(
698 "Compile CUDA C code failed from device module"));
699 VLOG(3) << "[CUDA] C:\n" << source_code;
700 SourceCodePrint::GetInstance()->write(source_code);
701 device_fn_code_ += source_code;
702
703 for (auto& fn : device_module.functions()) {
704 std::string kernel_fn_name = fn->name;
705 device_fn_name_.emplace_back(kernel_fn_name);
706 }
707 engine_->Link<CodeGenGpuHost>(host_module);
708#else
709 CINN_NOT_IMPLEMENTED
710#endif
711}
712
713void Compiler::CompileCustomDeviceModule(const Module& module,
714 const std::string& code) {

Callers

nothing calls this directly

Calls 8

SplitDeviceAndHostModuleFunction · 0.85
GetFileContentFunction · 0.85
GetInstanceFunction · 0.85
Link<CodeGenGpuHost>Method · 0.80
emptyMethod · 0.45
CompileMethod · 0.45
writeMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected