MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / loadProgramSource

Function loadProgramSource

cpp/7_libNVVM/device-side-launch/dsl.c:71–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71static char *loadProgramSource(const char *filename, size_t *size)
72{
73 assert(filename && size);
74 char *source = NULL;
75 *size = 0;
76 FILE *fh = fopen(filename, "rb");
77 if (fh) {
78 struct stat statbuf;
79 stat(filename, &statbuf);
80 source = (char *)malloc(statbuf.st_size + 1);
81 if (source) {
82 fread(source, statbuf.st_size, 1, fh);
83 source[statbuf.st_size] = 0;
84 *size = statbuf.st_size + 1;
85 }
86 }
87 else {
88 fprintf(stderr, "Error reading file %s\n", filename);
89 exit(EXIT_FAILURE);
90 }
91 return source;
92}
93
94// Compile the NVVM IR into PTX.
95static char *generatePTX(const char *ll, size_t size, const char *filename, int devMajor, int devMinor)

Callers 1

buildKernelFunction · 0.70

Calls 1

statClass · 0.70

Tested by

no test coverage detected