diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-11-12 11:24:51 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-11-12 11:24:51 -0500 |
| commit | d1472ff60bd12b4f834607de405737f08ef4491c (patch) | |
| tree | e3d6bd2915afa519d8082b0fffd8fbe21b3d1892 | |
| parent | 9413cb225caead02c3baac230bacb8a447b013ef (diff) | |
| download | balls-d1472ff60bd12b4f834607de405737f08ef4491c.zip | |
create cl contexts
| -rw-r--r-- | balls.c | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -187,19 +187,15 @@ initCL(void) { cl_context_properties cpuProperties[] = contextProperties(cpuPlatform); cl_context_properties gpuProperties[] = contextProperties(gpuPlatform); - /* Get GPU device. */ - 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); + /* Create contexts. */ + cpuContext = clCreateContext(cpuProperties, 1, &cpuDevice, NULL, NULL, &err); + if (err < 0) + sysfatal("Failed to create CPU context.\n"); + gpuContext = clCreateContext(gpuProperties, 1, &gpuDevice, NULL, NULL, &err); if (err < 0) - sysfatal("Failed to create context.\n"); + sysfatal("Failed to create GPU context.\n"); + + free(platforms); /* Create program from file. */ progBuf = readFile(PROG_FILE, &progSize); |