MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / getCodeGenSpec

Method getCodeGenSpec

cudaq/lib/Target/TargetConfig.cpp:12–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include <regex>
11
12std::string cudaq::config::TargetConfig::getCodeGenSpec(
13 const std::map<std::string, std::string> &targetArgs) const {
14 // Check whether we have a per-machine config
15 const auto machineConfigIter = std::find_if(
16 TargetArguments.begin(), TargetArguments.end(),
17 [&](const cudaq::config::TargetArgument &argConfig) {
18 return argConfig.Type == cudaq::config::ArgumentType::MachineConfig;
19 });
20 if (machineConfigIter == TargetArguments.end()) {
21 // No machine specific config
22 return BackendConfig.has_value() ? BackendConfig->CodegenEmission : "";
23 }
24
25 // Get the machine name from the CLI argument
26 std::string machineName;
27 for (const auto &[argKey, argVal] : targetArgs) {
28 if (argKey == machineConfigIter->PlatformArgKey) {
29 machineName = argVal;
30 break;
31 }
32 }
33
34 if (!machineName.empty()) {
35 // Check for match
36 for (auto &archConfig : machineConfigIter->MachineConfigs) {
37 // Check names first
38 if (std::find(archConfig.MachineNames.begin(),
39 archConfig.MachineNames.end(),
40 machineName) != archConfig.MachineNames.end()) {
41 return archConfig.Configuration.CodegenEmission;
42 }
43 // Check pattern if provided
44 if (!archConfig.MachinePattern.empty()) {
45 std::regex re(archConfig.MachinePattern);
46 if (std::regex_search(machineName, re)) {
47 return archConfig.Configuration.CodegenEmission;
48 }
49 }
50 }
51 }
52
53 // No machine specific config rule matches, fallback to the default backend
54 // config
55 return BackendConfig.has_value() ? BackendConfig->CodegenEmission : "";
56}
57
58bool cudaq::config::BackendEndConfigEntry::hasPassPipeline() const {
59 return !TargetPassPipeline.empty() || !JITHighLevelPipeline.empty() ||

Callers 4

getTransportLayerMethod · 0.80
CompileTargetMethod · 0.80
TESTFunction · 0.80
get_codegen_configMethod · 0.80

Calls 4

findFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by 1

TESTFunction · 0.64