Debian Codegraph @

Tests/CudaOnly/OptixIR/main.cu

raw
1 #include <cstdint>
2 #include <fstream>
3 #include <iostream>
4 #include <string>
5 #include <vector>
6
7 #include <cuda.h>
8
9 #define GENERATED_HEADER(x) GENERATED_HEADER1(x)
10 #define GENERATED_HEADER1(x) <x>
11
12 static std::string input_paths = { OPTIX_FILE_PATHS };
13
14 int main()
15 {
16 if (input_paths == "NO_OPTIX_SUPPORT") {
17 return 0;
18 }
19
20 std::string const delimiter = "~_~";
21 input_paths += delimiter;
22
23 size_t end = 0;
24 size_t previous_end = 0;
25 std::vector<std::string> actual_paths;
26 while ((end = input_paths.find(delimiter, previous_end)) !=
27 std::string::npos) {
28 actual_paths.emplace_back(
29 input_paths.substr(previous_end, end - previous_end));
30 previous_end = end + 3;
31 }
32
33 if (actual_paths.empty()) {
34 std::cerr << "Failed to parse OPTIX_FILE_PATHS" << std::endl;
35 return 1;
36 }
37
38 std::uint32_t const optix_magic_value = 0x7f4e43ed;
39 for (auto p : actual_paths) {
40 if (p.find(".optixir") == std::string::npos) {
41 std::cout << p << " Doesn't have the .optixir suffix" << p << std::endl;
42 return 1;
43 }
44 std::ifstream input(p, std::ios::binary);
45 std::uint32_t value;
46 input.read(reinterpret_cast<char*>(&value), sizeof(value));
47 if (value != optix_magic_value) {
48 std::cerr << p << " Doesn't look like an optix-ir file" << std::endl;
49 return 1;
50 }
51 }
52
53 return 0;
54 }