Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply environment variable CL_PLATFORM_INDEX to test_compute_info #1851

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions test_conformance/computeinfo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,30 @@ int test_computeinfo(cl_device_id deviceID, cl_context context,
int err;
int total_errors = 0;
cl_platform_id platform;

err = clGetPlatformIDs(1, &platform, NULL);
test_error(err, "clGetPlatformIDs failed");
cl_uint platform_num;

err = clGetPlatformIDs(0, NULL, &platform_num);
test_error(err, "clGetPlatformIDs failed in trying to get platform number");

char *env_mode=getenv("CL_PLATFORM_INDEX");
if(env_mode == NULL)
{
err = clGetPlatformIDs(1, &platform, NULL);
test_error(err, "clGetPlatformIDs failed");
}
else{
cl_uint platform_index_env = atoi(env_mode);
if(platform_index_env >= platform_num)
{
test_error(CL_INVALID_PLATFORM, "platform index out of range");
}
cl_platform_id* platform_id_temp_buffer = new cl_platform_id[platform_num];
err = clGetPlatformIDs(platform_num, platform_id_temp_buffer, NULL);
test_error(err, "clGetPlatformIDs failed");
platform = platform_id_temp_buffer[platform_index_env];
delete [] platform_id_temp_buffer;
}


// print platform info
log_info("\nclGetPlatformInfo:\n------------------\n");
Expand Down
Loading