QUDA  1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
jitify_helper.cuh
Go to the documentation of this file.
1 #pragma once
2 
11 #ifdef JITIFY
12 
13 #ifdef HOST_DEBUG
14 
15 // display debugging info
16 #define JITIFY_PRINT_INSTANTIATION 1
17 #define JITIFY_PRINT_SOURCE 1
18 #define JITIFY_PRINT_LOG 1
19 #define JITIFY_PRINT_PTX 1
20 #define JITIFY_PRINT_LAUNCH 1
21 
22 #else // !HOST_DEBUG
23 
24 // hide debugging info
25 #define JITIFY_PRINT_INSTANTIATION 0
26 #define JITIFY_PRINT_SOURCE 0
27 #define JITIFY_PRINT_LOG 0
28 #define JITIFY_PRINT_PTX 0
29 #define JITIFY_PRINT_LAUNCH 0
30 
31 #endif // !HOST_DEBUG
32 
33 #include "jitify_options.hpp"
34 #include <jitify.hpp>
35 
36 #endif
37 
38 namespace quda {
39 
40 #ifdef JITIFY
41 
42  static jitify::JitCache *kernel_cache = nullptr;
43  static jitify::Program *program = nullptr;
44  static bool jitify_init = false;
45 
46  static void create_jitify_program(const char *file, const std::vector<std::string> extra_options = {}) {
47 
48  if (!jitify_init) {
49  kernel_cache = new jitify::JitCache;
50 
51  std::vector<std::string> options = {"-std=c++11", "-ftz=true", "-prec-div=false", "-prec-sqrt=false"};
52 
53 #ifdef DEVICE_DEBUG
54  options.push_back(std::string("-G"));
55 #endif
56 
57  // add an extra compilation options specific to this instance
58  for (auto option : extra_options) options.push_back(option);
59 
60  program = new jitify::Program(kernel_cache->program(file, 0, options));
61  jitify_init = true;
62  }
63  }
64 
65 #endif
66 
67 } // namespace quda