Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //program.cpp
- #include <stdio.h>
- #include <CL/cl.h>
- void ErrStop(int err, char str[])
- {
- printf("Err %i: %s\n", err, str);
- exit(1);
- }
- int main()
- {
- cl_platform_id *platform;
- cl_device_id *device;
- int plat, dev;
- cl_uint nplat, ndev;
- char pname[256], dname[256];
- cl_device_type dtype;
- cl_uint dab;
- cl_ulong gs;
- cl_int err;
- plat = 0;
- dev = 0;
- err = clGetPlatformIDs(0, NULL, &nplat);
- printf(":::::::::::::::::::::::::::::::::::\n");
- if (err) ErrStop(err, (char*)"clGetPlatformIDs failed!");
- platform = (cl_platform_id*)calloc(nplat, sizeof(cl_platform_id));
- err = clGetPlatformIDs(nplat, platform, NULL);
- if (err) ErrStop(err, (char*)"clGetPlatformIDs failed!");
- err = clGetPlatformInfo(platform[plat], CL_PLATFORM_NAME, sizeof(pname), pname, NULL);
- if (err) ErrStop(err, (char*)"clGetPlatformInfo failed!");
- printf("Platform: %s\n", pname);
- dtype = CL_DEVICE_TYPE_ALL;
- err = clGetDeviceIDs(platform[plat], dtype, 0, NULL, &ndev);
- if(err) ErrStop(err, (char*)"clGetDeviceIDs failed!");
- device = (cl_device_id*)calloc(ndev, sizeof(cl_device_id));
- err = clGetDeviceIDs(platform[plat], dtype, ndev, device, NULL);
- if(err) ErrStop(err, (char*)"clGetDeviceIDs failed!");
- err = clGetDeviceInfo(device[dev], CL_DEVICE_NAME, sizeof(dname), dname, NULL);
- if(err) ErrStop(err, (char*)"clGetDeviceInfo failed");
- printf("CL_DEVICE_NAME: %s\n", dname);
- err = clGetDeviceInfo(device[dev], CL_DEVICE_ADDRESS_BITS, sizeof(dab), &dab, NULL);
- if(err) ErrStop(err, (char*)"clGetDeviceInfo failed");
- printf("CL_DEVICE_ADDRESS_BITS: %u\n", dab);
- err = clGetDeviceInfo(device[dev], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(gs), &gs, NULL);
- if(err) ErrStop(err, (char*)"clGetDeviceInfo failed");
- printf("CL_DEVICE_GLOBAL_MEM_SIZE: %u\n", gs);
- free(device);
- free(platform);
- printf(":::::::::::::::::::::::::::::::::::\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement