summaryrefslogtreecommitdiffstats
path: root/balls.c
diff options
context:
space:
mode:
Diffstat (limited to 'balls.c')
-rw-r--r--balls.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/balls.c b/balls.c
index bf81517..9e2522a 100644
--- a/balls.c
+++ b/balls.c
@@ -129,8 +129,13 @@ initCL(void) {
#endif
/* Get GPU device. */
- if (clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL) < 0)
- sysfatal("No GPUs available.\n");
+ err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);
+ if (err < 0) {
+ fprintf(stderr, "No GPU available, falling back to CPU.\n");
+ err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &device, NULL);
+ if (err < 0)
+ sysfatal("No CL devices available.\n");
+ }
/* Create context. */
context = clCreateContext(properties, 1, &device, NULL, NULL, &err);