From 73a4a9569041c984416466aacb42be2d8868dad3 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Tue, 29 Oct 2024 20:16:06 -0400 Subject: ball-ball collisions (untested) --- balls.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'balls.c') 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); -- cgit v1.2.3