commit 9b5eda68d416e1fbcb195d77a4b243188dc9f35d
parent 4152c2a6ad64485ce22e9cd4eba13e22a7b5a2e5
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 18 Nov 2023 20:33:29 +0100
init platforms (again)
Diffstat:
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/source/rsa-test.c b/source/rsa-test.c
@@ -633,12 +633,27 @@ int rsa_tests(void) {
//cl_mem input; // device memory used for the input array
//cl_mem output; // device memory used for the output array
+ cl_uint max_platforms = 4;
+ cl_platform_id platforms[max_platforms];
+ cl_uint num_platforms;
+ cl_int rplat;
-
+ rplat = clGetPlatformIDs (max_platforms, platforms, &num_platforms);
+ if (rplat != CL_SUCCESS)
+ {
+ printf("Error: Failed to lookup platforms! (%d)\n", rplat);
+ return EXIT_FAILURE;
+ }
+ printf("Found %u platforms\n", (unsigned int) num_platforms);
+ if (0 == num_platforms)
+ {
+ return EXIT_FAILURE;
+ }
// Connect to a compute device
//
int gpu = 1;
- err = clGetDeviceIDs(NULL, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);
+ err = clGetDeviceIDs(platforms[0],
+ gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);
if (err != CL_SUCCESS)
{
printf("Error: Failed to create a device group!\n");