MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / saveKernel

Function saveKernel

src/backend/common/util.cpp:112–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void saveKernel(const string& funcName, const string& jit_ker,
113 const string& ext) {
114 static constexpr const char* saveJitKernelsEnvVarName =
115 "AF_JIT_KERNEL_TRACE";
116 static const char* jitKernelsOutput = getenv(saveJitKernelsEnvVarName);
117 if (!jitKernelsOutput) { return; }
118 if (strcmp(jitKernelsOutput, "stdout") == 0) {
119 fputs(jit_ker.c_str(), stdout);
120 return;
121 }
122 if (strcmp(jitKernelsOutput, "stderr") == 0) {
123 fputs(jit_ker.c_str(), stderr);
124 return;
125 }
126 // Path to a folder
127 const string ffp =
128 string(jitKernelsOutput) + AF_PATH_SEPARATOR + funcName + ext;
129
130#if defined(OS_WIN)
131 FILE* f = fopen(ffp.c_str(), "w");
132#else
133 FILE* f = fopen(ffp.c_str(), "we");
134#endif
135
136 if (!f) {
137 fprintf(stderr, "Cannot open file %s\n", ffp.c_str());
138 return;
139 }
140 if (fputs(jit_ker.c_str(), f) == EOF) {
141 fprintf(stderr, "Failed to write kernel to file %s\n", ffp.c_str());
142 }
143 fclose(f);
144}
145
146#if defined(OS_WIN)
147string getTemporaryDirectory() {

Callers 2

getKernelFunction · 0.85
getKernelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected