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

Function parseRuntimeTarget

python/utils/LinkedLibraryHolder.cpp:56–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54int num_available_gpus();
55
56void parseRuntimeTarget(const std::filesystem::path &cudaqLibPath,
57 RuntimeTarget &target,
58 const std::string nvqppBuildConfig) {
59 simulation_precision precision = simulation_precision::fp32;
60 std::optional<std::string> foundPlatformName, foundSimulatorName;
61 for (auto &line : cudaq::split(nvqppBuildConfig, '\n')) {
62 if (line.find(PLATFORM_LIBRARY) != std::string::npos) {
63 cudaq::trim(line);
64 auto platformName = cudaq::split(line, '=')[1];
65 // Post-process the string
66 platformName.erase(
67 std::remove(platformName.begin(), platformName.end(), '\"'),
68 platformName.end());
69 platformName = std::regex_replace(platformName, std::regex("-"), "_");
70 foundPlatformName = platformName;
71 } else if (line.find(NVQIR_SIMULATION_BACKEND) != std::string::npos &&
72 !foundSimulatorName.has_value()) {
73 cudaq::trim(line);
74 auto simulatorName = cudaq::split(line, '=')[1];
75 // Post-process the string
76 simulatorName.erase(
77 std::remove(simulatorName.begin(), simulatorName.end(), '\"'),
78 simulatorName.end());
79
80#if defined(__APPLE__) && defined(__MACH__)
81 const std::string libSuffix = "dylib";
82#else
83 const std::string libSuffix = "so";
84#endif
85 CUDAQ_INFO("CUDA-Q Library Path is {}.", cudaqLibPath.string());
86 const auto libName =
87 fmt::format("libnvqir-{}.{}", simulatorName, libSuffix);
88
89 if (std::filesystem::exists(cudaqLibPath / libName)) {
90 CUDAQ_INFO("Use {} simulator for target {}", simulatorName,
91 target.name);
92 foundSimulatorName =
93 std::regex_replace(simulatorName, std::regex("-"), "_");
94 } else {
95 CUDAQ_INFO("Skip {} simulator for target {} since it is not available",
96 simulatorName, target.name);
97 }
98 } else if (line.find(IS_FP64_SIMULATION) != std::string::npos) {
99 precision = simulation_precision::fp64;
100 }
101 }
102 target.platformName = foundPlatformName.value_or("default");
103 target.simulatorName = foundSimulatorName.value_or("");
104 target.precision = precision;
105}
106
107/// @brief Search the targets folder in the install for available targets.
108void findAvailableTargets(

Callers 2

findAvailableTargetsFunction · 0.85
setTargetMethod · 0.85

Calls 7

trimFunction · 0.85
formatFunction · 0.85
eraseMethod · 0.80
splitFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected