forked from Theano/libgpuarray
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpuarray_extension.c
More file actions
54 lines (48 loc) · 1.24 KB
/
gpuarray_extension.c
File metadata and controls
54 lines (48 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <string.h>
#include "gpuarray/extension.h"
typedef struct _ext {
const char *name;
void *val;
} ext;
#ifdef WITH_CUDA
extern void cuda_enter(void);
extern void cuda_exit(void);
extern void *cuda_make_ctx(void);
extern void *cuda_get_stream(void);
extern void *cuda_make_buf(void);
extern void *cuda_get_sz(void);
extern void *cuda_wait(void);
extern void *cuda_record(void);
#endif
#ifdef WITH_OPENCL
extern void *cl_make_ctx(void);
extern void *cl_get_stream(void);
extern void *cl_make_buf(void);
extern void *cl_get_buf(void);
#endif
static ext ext_list[] = {
#ifdef WITH_CUDA
{"cuda_enter", cuda_enter},
{"cuda_exit", cuda_exit},
{"cuda_make_ctx", cuda_make_ctx},
{"cuda_get_stream", cuda_get_stream},
{"cuda_make_buf", cuda_make_buf},
{"cuda_get_sz", cuda_get_sz},
{"cuda_wait", cuda_wait},
{"cuda_record", cuda_record},
#endif
#ifdef WITH_OPENCL
{"cl_make_ctx", cl_make_ctx},
{"cl_get_stream", cl_get_stream},
{"cl_make_buf", cl_make_buf},
{"cl_get_buf", cl_get_buf},
#endif
};
#define N_EXT (sizeof(ext_list)/sizeof(ext_list[0]))
void *gpuarray_get_extension(const char *name) {
unsigned int i;
for (i = 0; i < N_EXT; i++) {
if (strcmp(name, ext_list[i].name) == 0) return ext_list[i].val;
}
return NULL;
}