IGP of Ivy bridge can't be found by OpenCL SDK - opencl

I have set up a IvyBridge platform for coding OpenCL program. My system is win7 64-bit, VS2010 as developement tools. There is one i7-3770k with a nVidia GTX560 on my PC. When I queried the devices of my system, I cann't find HD4000. I have checked my system driver for HD4000 by using this webpage: http://www.intel.com/p/en_US/support/detect/graphics. The report said "Current Driver Installed 8.15.10.2696". OpenCL SDK is the latest Intel SDK for OpenCL Application 2012 windows 64-bit downloaded from http://software.intel.com/en-us/articles/vcsource-tools-opencl-sdk/. The following is my code and the output.
I also noticed that the device name of CPU is very strange. By the way, I have connected the HD4000 device to a monitor since I found someone met the issue that failed to create a CL context. And now I can find HD4000 can be detected by GPU-Z tool after we connected a monitor to HD4000. So anyone can help me solve this problem?
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <CL/cl.h>
int _tmain(int argc, _TCHAR* argv[])
{
cl_platform_id *platforms;
cl_uint num_platforms;
cl_device_id *devices_cpu, *devices_gpu;
cl_uint num_devices;
char dev_name[40], dev_vendor[40], dev_version[40], dev_profile[40];
char plt_name[40], plt_vendor[40], plt_version[40], plt_profile[40];
clGetPlatformIDs(1, NULL, &num_platforms);
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * num_platforms);
clGetPlatformIDs(num_platforms, platforms, NULL);
for(int i = num_platforms - 1; i >= 0; i--)
{
clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, sizeof(plt_name),&plt_name,NULL);
clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, sizeof(plt_vendor),&plt_vendor,NULL);
clGetPlatformInfo(platforms[i], CL_PLATFORM_VERSION, sizeof(plt_version),&plt_version,NULL);
clGetPlatformInfo(platforms[i], CL_PLATFORM_PROFILE, sizeof(plt_profile),&plt_profile,NULL);
printf("\n\n\nPlatform #%d Info: \n\n", i);
printf("Platform: %s \n", plt_name);
printf("Vendor: %s \n", plt_vendor);
printf("Version: %s \n", plt_version);
printf("Profile: %s \n", plt_profile);
clGetDeviceIDs(platforms[i],CL_DEVICE_TYPE_CPU, 1, NULL, &num_devices);
devices_cpu = (cl_device_id *)malloc(sizeof(cl_device_id) * num_devices);
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_CPU, num_devices, devices_cpu, NULL);
for(int j = 0 ; j < num_devices; j++)
{
clGetDeviceInfo(devices_cpu[j], CL_DEVICE_NAME, sizeof(dev_name), &dev_name, NULL);
clGetDeviceInfo(devices_cpu[j], CL_DEVICE_VENDOR, sizeof(dev_vendor), &dev_vendor, NULL);
clGetDeviceInfo(devices_cpu[j], CL_DEVICE_VERSION, sizeof(dev_version), &dev_version, NULL);
clGetDeviceInfo(devices_cpu[j], CL_DEVICE_PROFILE, sizeof(dev_profile), &dev_profile, NULL);
printf("\n\n\nCPU Device Info: \n\n");
printf("Name: %s \n", dev_name);
printf("Vendor: %s \n", dev_vendor);
printf("Version: %s \n", dev_version);
printf("Profile: %s \n", dev_profile);
}
clGetDeviceIDs(platforms[i],CL_DEVICE_TYPE_GPU, 1, NULL, &num_devices);
devices_gpu = (cl_device_id *)malloc(sizeof(cl_device_id) * num_devices);
clGetDeviceIDs(platforms[i],CL_DEVICE_TYPE_GPU, num_devices, devices_gpu, NULL);
for(int j = 0; j < num_devices; j++)
{
clGetDeviceInfo(devices_gpu[j], CL_DEVICE_NAME, sizeof(dev_name), &dev_name, NULL);
clGetDeviceInfo(devices_gpu[j], CL_DEVICE_VENDOR, sizeof(dev_vendor), &dev_vendor, NULL);
clGetDeviceInfo(devices_gpu[j], CL_DEVICE_VERSION, sizeof(dev_version), &dev_version, NULL);
clGetDeviceInfo(devices_gpu[j], CL_DEVICE_PROFILE, sizeof(dev_profile), &dev_profile, NULL);
printf("\n\n\nGPU Device Info: \n\n");
printf("Platform: %s \n", dev_name);
printf("Vendor: %s \n", dev_vendor);
printf("Version: %s \n", dev_version);
printf("Profile: %s \n", dev_profile);
}
free((void*)devices_cpu);
free((void*)devices_gpu);
}
return 0;
}
output:
Platform #1 Info:
Platform: Intel(R) OpenCL
Vendor: Intel(R) Corporation
Version: OpenCL 1.1
Profile: FULL_PROFILE
CPU Device Info:
Name: ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌIntel(R) Corporation
Vendor: Intel(R) Corporation
Version: OpenCL 1.1 (Build 31360.31441)
Profile: FULL_PROFILE
Platform #0 Info:
Platform: NVIDIA CUDA
Vendor: NVIDIA Corporation
Version: OpenCL 1.1 CUDA 4.2.1
Profile: FULL_PROFILE
GPU Device Info:
Platform: GeForce GTX 560 Ti
Vendor: NVIDIA Corporation
Version: OpenCL 1.1 CUDA
Profile: FULL_PROFILE

OpenCL does not work on HD4000 if there is no display connected to the card.
This is from my own testing and answers in Intel forums.
See these threads on Intel forums: 1 2 3.

Related

OpenCL clFinish never returns

I'm looking to start learning OpenCL. I was looking for a "hello world" example in order to first verify that everything behaves as expected on my system. After trying multiple such examples, I'm unable to find (or to make) one that works.
The code below is blocking on the call to clFinish and appears to never return.
#include <math.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
const char *KernelSource = "\n" \
"__kernel void hello( \n" \
" __global char* a, \n" \
" __global char* b, \n" \
" __global char* c, \n" \
" const unsigned int count) \n" \
"{ \n" \
" int i = get_global_id(0); \n" \
" if(i < count) \n" \
" c[i] = a[i] + b[i]; \n" \
"} \n" \
"\n";
#define DATA_SIZE (16)
int main(int argc, char** argv)
{
int err; // error code returned from api calls
cl_device_id device_id; // compute device id
cl_context context; // compute context
cl_command_queue commands; // compute command queue
cl_program program; // compute program
cl_kernel kernel; // compute kernel
cl_mem input; // device memory used for the input array
cl_mem input2; // device memory used for the input array
cl_mem output; // device memory used for the output array
size_t global; // global domain size for our calculation
size_t local; // local domain size for our calculation
int i;
unsigned int count = DATA_SIZE;
// Input data
char a[DATA_SIZE] = "Hello \0\0\0\0\0\0";
char b[DATA_SIZE] = {15, 10, 6, 0, -11, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// Output data
char c[DATA_SIZE];
cl_platform_id platform;
unsigned int no_plat;
err = clGetPlatformIDs(1,&platform,&no_plat);
// Where to run
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
if (err != CL_SUCCESS) return -1;
context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
if (!context) return -1;
commands = clCreateCommandQueue(context, device_id, 0, &err);
if (!commands) return -1;
// What to run
program = clCreateProgramWithSource(context, 1, (const char **) & KernelSource, NULL, &err);
if (!program) return -1;
err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
if (err != CL_SUCCESS) return -1;
kernel = clCreateKernel(program, "hello", &err);
if (!kernel || err != CL_SUCCESS) return -1;
// Create space for data and copy a and b to device (note that we could also use clEnqueueWriteBuffer to upload)
input = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, sizeof(char) * DATA_SIZE, a, NULL);
input2 = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, sizeof(char) * DATA_SIZE, b, NULL);
output = clCreateBuffer(context, CL_MEM_WRITE_ONLY, sizeof(char) * DATA_SIZE, NULL, NULL);
if (!input || !output) return -1;
// Send data
err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &input);
err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &input2);
err |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &output);
err |= clSetKernelArg(kernel, 3, sizeof(unsigned int), &count);
if (err != CL_SUCCESS) return -1;
local = DATA_SIZE;
// Run kernel!
global = DATA_SIZE; // count;
err = clEnqueueNDRangeKernel(commands, kernel, 1, NULL, &global, &local, 0, NULL, NULL);
if (err != CL_SUCCESS) return -1;
clFinish(commands);
// Read result
err = clEnqueueReadBuffer( commands, output, CL_TRUE, 0, sizeof(char) * count, c, 0, NULL, NULL );
if (err != CL_SUCCESS) return -1;
printf("%s\n", c);
// Clean up
clReleaseMemObject(input);
clReleaseMemObject(output);
clReleaseProgram(program);
clReleaseKernel(kernel);
clReleaseCommandQueue(commands);
clReleaseContext(context);
sleep(1); // Leopard pty bug workaround.
return 0;
}
I have a Ryzen 5 3400G and I'm using Linux.
gcc (Debian 10.2.1-6) 10.2.1 20210110
During compilation I see a couple of warnings (I couldn't find an example that gives no warnings).
from world.c:11:
/usr/include/CL/cl_version.h:22:9: note: ‘#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)’
22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
| ^~~~~~~
world.c: In function ‘main’:
world.c:61:2: warning: ‘clCreateCommandQueue’ is deprecated [-Wdeprecated-declarations]
61 | commands = clCreateCommandQueue(context, device_id, 0, &err);
| ^~~~~~~~
In file included from world.c:11:
/usr/include/CL/cl.h:1906:1: note: declared here
1906 | clCreateCommandQueue(cl_context context,
| ^~~~~~~~~~~~~~~~~~~~
Am I doing something wrong or is the example wrong? In the latter case, where can I find a simple opencl program that works?
EDIT
I happened to restart the computer and clinfo works after the restart:
Number of platforms 1
Platform Name Clover
Platform Vendor Mesa
Platform Version OpenCL 1.1 Mesa 20.3.5
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_icd
Platform Extensions function suffix MESA
Platform Name Clover
Number of devices 1
Device Name AMD Radeon(TM) Vega 11 Graphics (RAVEN, DRM 3.40.0, 4.19.0-12-amd64, LLVM 11.0.1)
Device Vendor AMD
Device Vendor ID 0x1002
Device Version OpenCL 1.1 Mesa 20.3.5
Driver Version 20.3.5
Device OpenCL C Version OpenCL C 1.1
Device Type GPU
Device Profile FULL_PROFILE
Device Available Yes
Compiler Available Yes
Max compute units 11
Max clock frequency 1400MHz
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 256
Preferred work group size multiple (kernel) 64
Preferred / native vector sizes
char 16 / 16
short 8 / 8
int 4 / 4
long 2 / 2
half 0 / 0 (n/a)
float 4 / 4
double 2 / 2 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals No
Infinity and NANs Yes
Round to nearest Yes
Round to zero No
Round to infinity No
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Address bits 64, Little-Endian
Global memory size 31611129856 (29.44GiB)
Error Correction support No
Max memory allocation 22127790899 (20.61GiB)
Unified memory for Host and Device No
Minimum alignment for any data type 128 bytes
Alignment of base address 32768 bits (4096 bytes)
Global Memory cache type None
Image support No
Local memory type Local
Local memory size 32768 (32KiB)
Max number of constant args 16
Max constant buffer size 67108864 (64MiB)
Max size of kernel argument 1024
Queue properties
Out-of-order execution No
Profiling Yes
Profiling timer resolution 0ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
Device Extensions cl_khr_byte_addressable_store cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp64
NULL platform behavior
clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) No platform
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) No platform
clCreateContext(NULL, ...) [default] No platform
clCreateContext(NULL, ...) [other] Success [MESA]
clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) Success (1)
Platform Name Clover
Device Name AMD Radeon(TM) Vega 11 Graphics (RAVEN, DRM 3.40.0, 4.19.0-12-amd64, LLVM 11.0.1)
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1)
Platform Name Clover
Device Name AMD Radeon(TM) Vega 11 Graphics (RAVEN, DRM 3.40.0, 4.19.0-12-amd64, LLVM 11.0.1)
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1)
Platform Name Clover
Device Name AMD Radeon(TM) Vega 11 Graphics (RAVEN, DRM 3.40.0, 4.19.0-12-amd64, LLVM 11.0.1)
I checked the sample code, it executes properly. So there must be an issue with your OpenCL Runtime installation. Did a reboot fix it already? Are you on Windows or Linux?

OpenCL pipes on intel CPU

I am working on my dissertation project trying to investigate if and when the use of OpenCL pipes can be useful also on CPUs (we already know they are widely used in FPGAs).
I am trying to implement even the simplest algorithm where I have a producer (writing to the pipe) and a consumer kernel (reading from the pipe). I would like to execute the two kernels in parallel and have a blocking behaviour for the pipe (read only when the pipe is not empty). Reading on Intel documentation at Intel_FPGA_Opencl it is explained that the attribute __attribute__((blocking)) declared for the pipe should have the read operation blocking when the pipe is empty. However, when I try to use the attribute I get __write_pipe_2_bl is undefined. I even tried to emulate the blocking behaviour with a while loop (as shown in the intel documentation) but the kernel stalls even if the pipe is not empty.
Furthermore, the kernels seem not to run in parallel unless I use two different command queues.
Kernel code:
#pragma OPENCL EXTENSION cl_intel_printf : enable
#define SIZE 1000
__kernel void pipe_writer(__global int *in,
write_only pipe int __attribute((depth(SIZE))) p)
{
for(int i = 0; i < SIZE; i++){
write_pipe(p, &in[i]);
printf("written: %d\n", in[i]);
}
}
__kernel void pipe_reader(__global int *out,
read_only pipe int __attribute((depth(SIZE))) p)
{
for(int i = 0; i < SIZE; i++){
while (read_pipe(p, &out[i]) == -1){
//printf("blocked read\n";
}
//int check = read_pipe(p, &out[i]);
printf("read: %d\n", out[i]);
}
}
Host Code:
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
#define MAX_SOURCE_SIZE (0x100000)
int main(void) {
// Create the two input vectors
int bb = 0;
int i;
const int LIST_SIZE = 1000;
int *A = (int*)malloc(sizeof(int)*LIST_SIZE);
int *B = (int*)malloc(sizeof(int)*LIST_SIZE);
for(i = 0; i < LIST_SIZE; i++) {
A[i] = i;
}
// Load the kernel source code into the array source_str
FILE *fp;
char *source_str;
size_t source_size;
fp = fopen("kernel.cl", "r");
if (!fp) {
fprintf(stderr, "Failed to load kernel.\n");
exit(1);
}
source_str = (char*)malloc(MAX_SOURCE_SIZE);
source_size = fread( source_str, 1, MAX_SOURCE_SIZE, fp);
fclose( fp );
// Get platform and device information
cl_platform_id platform_id = NULL;
cl_device_id device_id = NULL;
cl_uint ret_num_devices;
cl_uint ret_num_platforms;
cl_int ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
if(ret != CL_SUCCESS){
printf("getPlatformId, ERROR CODE: %d\n", ret);
bb=1;
}
ret = clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_CPU, 1,
&device_id, &ret_num_devices);
if(ret != CL_SUCCESS){
printf("getDevice, ERROR CODE: %d\n", ret);
bb=1;
}
// Create an OpenCL context
cl_context context = clCreateContext( NULL, 1, &device_id, NULL, NULL, &ret);
if(ret != CL_SUCCESS){
printf("createContext, ERROR CODE: %d\n", ret);
bb=1;
}
// Create a command queue
cl_command_queue command_queue = clCreateCommandQueue(context, device_id, 0, &ret);
cl_command_queue command_queue2 = clCreateCommandQueue(context, device_id, 0, &ret);
if(ret != CL_SUCCESS){
printf("commandQueue, ERROR CODE: %d\n", ret);
bb=1;
}
// Create memory buffers on the device for each vector
cl_mem a_mem_obj = clCreateBuffer(context, CL_MEM_READ_ONLY,
LIST_SIZE * sizeof(int), NULL, &ret);
cl_mem b_mem_obj = clCreateBuffer(context, CL_MEM_WRITE_ONLY,
LIST_SIZE * sizeof(int), NULL, &ret);
if(ret != CL_SUCCESS){
printf("memobj, ERROR CODE: %d\n", ret);
bb=1;
}
ret = clEnqueueWriteBuffer(command_queue, a_mem_obj, CL_TRUE, 0,
LIST_SIZE * sizeof(int), A, 0, NULL, NULL);
if(ret != CL_SUCCESS){
printf("enqueuewritebuffer, ERROR CODE: %d\n", ret);
bb=1;
}
cl_program program = clCreateProgramWithSource(context, 1,
(const char **)&source_str, (const size_t *)&source_size, &ret);
if(ret != CL_SUCCESS){
printf("crateProgWithSource, ERROR CODE: %d\n", ret);
bb=1;
}
// Build the program
ret = clBuildProgram(program, 1, &device_id, "-cl-std=CL2.0", NULL, NULL);
if(ret != CL_SUCCESS){
printf("buildProgram, ERROR CODE: %d\n", ret);
bb=1;
}
/////Debug Kernel compilation:
size_t ret_val_size;
clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
char * build_log = (char*) malloc(sizeof(char) * (ret_val_size));
clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
printf("LOG: \n%s\n", build_log);
///////////////////////////////
cl_kernel pipe_writer = clCreateKernel(program, "pipe_writer", &ret);
if(ret != CL_SUCCESS){
printf("createkernelwriter, ERROR CODE: %d\n", ret);
bb=1;
}
cl_kernel pipe_reader = clCreateKernel(program, "pipe_reader", &ret);
if(ret != CL_SUCCESS){
printf("createkernelReader, ERROR CODE: %d\n", ret);
bb=1;
}
cl_mem pipe = clCreatePipe(context, 0, sizeof(cl_int), 1000, NULL, &ret);
if(ret != CL_SUCCESS){
printf("createPipe, ERROR CODE: %d\n", ret);
bb=1;
}
// Set the arguments of the kernel
ret = clSetKernelArg(pipe_writer, 0, sizeof(cl_mem), (void *)&a_mem_obj);
if(ret != CL_SUCCESS){
printf("setArgWriterZERO, ERROR CODE: %d\n", ret);
bb=1;
}
ret = clSetKernelArg(pipe_writer, 1, sizeof(cl_mem), &pipe);
if(ret != CL_SUCCESS){
printf("setArgWriterONE, ERROR CODE: %d\n", ret);
bb=1;
}
ret = clSetKernelArg(pipe_reader, 0, sizeof(cl_mem), (void *)&b_mem_obj);
if(ret != CL_SUCCESS){
printf("setArgReaderZERO, ERROR CODE: %d\n", ret);
bb=1;
}
ret = clSetKernelArg(pipe_reader, 1, sizeof(cl_mem), &pipe);
if(ret != CL_SUCCESS){
printf("setArgReaderONE, ERROR CODE: %d\n", ret);
bb=1;
}
// Execute the OpenCL kernel on the list
size_t global_item_size = 1; // Process the entire lists
size_t local_item_size = 1; // Divide work items into groups of 64
cl_event sync; //??
ret = clEnqueueTask (command_queue, pipe_writer, NULL, NULL, NULL);
if(ret != CL_SUCCESS){
printf("EnqueueKernelWriter, ERROR CODE: %d\n", ret);
bb=1;
}
if(ret != CL_SUCCESS){
printf("EnqueueKernelwriter, ERROR CODE: %d\n", ret);
bb=1;
}
ret = clEnqueueTask (command_queue2, pipe_reader, NULL, NULL, NULL);
if(ret != CL_SUCCESS){
printf("EnqueueKernelWriter, ERROR CODE: %d\n", ret);
bb=1;
}
if(ret != CL_SUCCESS){
printf("EnqueueKernelReader, ERROR CODE: %d\n", ret);
bb=1;
}
ret = clEnqueueReadBuffer(command_queue2, b_mem_obj, CL_TRUE, 0,
LIST_SIZE * sizeof(int), B, 0, NULL, NULL);
if(ret != CL_SUCCESS){
printf("EnqueueReadBuffer, ERROR CODE: %d\n", ret);
bb=1;
}
if(bb == 0){
// Display the result to the screen
for(i = 0; i < LIST_SIZE; i++)
printf("%d and %d\n", A[i], B[i]);
}
// Clean up
ret = clFlush(command_queue);
ret = clFinish(command_queue);
ret = clReleaseKernel(pipe_writer);
ret = clReleaseKernel(pipe_reader);
ret = clReleaseProgram(program);
ret = clReleaseMemObject(a_mem_obj);
ret = clReleaseMemObject(b_mem_obj);
ret = clReleaseCommandQueue(command_queue);
ret = clReleaseContext(context);
free(A);
free(B);
return 0;
}
And this is what I get about the CPU I am using running 'clinfo':
Platform Name Intel(R) CPU Runtime for OpenCL(TM) Applications
Number of devices 1
Device Name Intel(R) Xeon(R) CPU E5-2698 v4 # 2.20GHz
Device Vendor Intel(R) Corporation
Device Vendor ID 0x8086
Device Version OpenCL 2.1 (Build 0)
Driver Version 18.1.0.0920
Device OpenCL C Version OpenCL C 2.0
Device Type CPU
Device Profile FULL_PROFILE
Max compute units 80
Max clock frequency 2200MHz
Device Partition (core)
Max number of sub-devices 80
Supported partition types by counts, equally, by names (Intel)
Max work item dimensions 3
Max work item sizes 8192x8192x8192
Max work group size 8192
Preferred work group size multiple 128
Max sub-groups per work group 1
Preferred / native vector sizes
char 1 / 32
short 1 / 16
int 1 / 8
long 1 / 4
half 0 / 0 (n/a)
float 1 / 8
double 1 / 4 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero No
Round to infinity No
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Address bits 64, Little-Endian
Global memory size 540956721152 (503.8GiB)
Error Correction support No
Max memory allocation 135239180288 (126GiB)
Unified memory for Host and Device Yes
Shared Virtual Memory (SVM) capabilities (core)
Coarse-grained buffer sharing Yes
Fine-grained buffer sharing Yes
Fine-grained system sharing Yes
Atomics Yes
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Preferred alignment for atomics
SVM 64 bytes
Global 64 bytes
Local 0 bytes
Max size for global variable 65536 (64KiB)
Preferred total size of global vars 65536 (64KiB)
Global Memory cache type Read/Write
Global Memory cache size 262144
Global Memory cache line 64 bytes
Image support Yes
Max number of samplers per kernel 480
Max size for 1D images from buffer 8452448768 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 64 bytes
Pitch alignment for 2D image buffers 64 bytes
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 480
Max number of write image args 480
Max number of read/write image args 480
Max number of pipe args 16
Max active pipe reservations 3276
Max pipe packet size 1024
Local memory type Global
Local memory size 32768 (32KiB)
Max constant buffer size 131072 (128KiB)
Max number of constant args 480
Max size of kernel argument 3840 (3.75KiB)
Queue properties (on host)
Out-of-order execution Yes
Profiling Yes
Local thread execution (Intel) Yes
Queue properties (on device)
Out-of-order execution Yes
Profiling Yes
Preferred size 4294967295 (4GiB)
Max size 4294967295 (4GiB)
Max queues on device 4294967295
Max events on device 4294967295
Prefer user sync for interop No
Profiling timer resolution 1ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
Sub-group independent forward progress No
IL version SPIR-V_1.0
SPIR versions 1.2
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Available Yes
Compiler Available Yes
Linker Available Yes
Device Extensions cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 cl_khr_image2d_from_buffer cl_intel_vec_len_hint
OpenCL 2.0 Pipes used for Intel FPGA are quite different from the
standard OpenCL 2.0 used for CPU.
One important difference is that standard OpenCL 2.0 Pipes are not
meant to be used to establish a communication between concurrent
kernels. Pipes are a subclass of memory objects and their state is
enforced only at a syncronization point (see s3.3.1 Memory Consistency
of OpenCL 1.2 Specification), where syncronization point is either a
command queue barrier, or a wait on event (see s3.4.3
Synchronization). In other words, according to the OpenCL
Specification, data written to a pipe is only visible when the kernel
finishes execution.
Intel OpenCL for FPGA have additional features (extensions) to make
OpenCL 2.0 Pipes usable for FPGA: specifically, it guarantess that
kernels can communicate over pipes, and provides a few extensions to
make such communication simpler and more efficient (blocking pipes,
host pipes, pipe depth). All these features are not supported by
Intel OpenCL runtime for CPU.
However, for the purpose of your dissertation project, you can look at
the Fast Emulator from Intel FPGA SDK: basically it is a CPU runtime
that supports FPGA extensions, including pipes (with kernel-to-kernel communication) and host pipes. See
https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/opencl-sdk/aocl_programming_guide.pdf
s8.7. Using the Fast Emulator (Preview).
Furthermore, the kernels seem not to run in parallel unless I use two different command queues.
If you don't create a command queue with
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, a queue is in-order, meaning
that there is an implicit dependency between commands pushed to this
queue, so they cannot run in parallel.
Also, you should call clFlush(command_queue) before
clEnqueueReadBuffer(command_queue2, ...) to ensure that the writer
kernel is started before you make a blocking call for the reader.

Accessing platforms and devices in AMD OpenCL platform

I'm trying to run my first codes in OpenCL. I wrote the following program to detect the available platforms and devices in my computer. The code works fine in my computer which has Intel CPU and NVIDIA GPU. It detects every platform and device correctly. But, when I run it on a computer with AMD-FX 770K and Radeon R7 240, the output is as the figure shown below. At least, it must show the Radeon R7 240 GPU as a device in this platform, but it doesn't. Any idea why the code is not working properly on AMD platform?
Here is the code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <CL/cl.h>
int main(){
cl_int err, i, j;
cl_platform_id *platforms;
cl_device_id *devices;
cl_uint num_platforms, num_devices;
size_t plat_name_size, devi_name_size;
char *plat_name_data, *devi_name_data;
err = clGetPlatformIDs(1, NULL, &num_platforms);
if (err < 0){
perror("No platform is found");
exit(1);
}
platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id)*num_platforms);
clGetPlatformIDs(num_platforms, platforms, NULL);
printf("Number of found platforms is %d\n ", num_platforms);
for (i = 0; i < num_platforms; i++){
err = clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, 0, NULL, &plat_name_size);
if (err < 0){
perror("Couldn't read platform name.");
exit(1);
}
plat_name_data = (char*)malloc(plat_name_size);
clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, plat_name_size, plat_name_data, NULL);
printf("Platform No.%d is: %s\n", i, plat_name_data);
free(plat_name_data);
err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 1, NULL, &num_devices);
if (err < 0){
perror("No device is found in this platform");
exit(1);
}
devices = (cl_device_id*)malloc(sizeof(cl_device_id)*(num_devices));
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, num_devices, devices, NULL);
printf("Number of devices found in this platform is: %d\n", num_devices);
for (j = 0; j < num_devices; j++){
err = clGetDeviceInfo(devices[j], CL_DEVICE_NAME, 0, NULL, &devi_name_size);
if (err < 0){
perror("Couldn't read the device name.");
exit(1);
}
devi_name_data = (char*)malloc(devi_name_size);
clGetDeviceInfo(devices[j], CL_DEVICE_NAME, devi_name_size, devi_name_data, NULL);
printf("Device No.%d name is: %s\n", j, devi_name_data);
free(devi_name_data);
}
}
return 0;
}
Please set num_entries to "0" in both of below calls:
clGetPlatformIDs(0 /* num_entries */_, NULL, &num_platforms);
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0 /* num_entries */, NULL, &num_devices);

Variadic Macros in OpenCL: Where are they supported?

I have been trying to find information on the (non-standard, cf. 1.0, 1.1, 1.2, 2.0) support for variadic macros in OpenCL implementations.
I have access to the following platforms, all of which support variadic macros:
Mac OS X, Intel CPU, OpenCL 1.2, driver: 1.1
Mac OS X, Intel GPU, OpenCL 1.2, driver: 1.2(Dec 23 2014 00:18:31)
Mac OS X, ATI GPU, OpenCL 1.2, driver: 1.2 (Aug 17 2014 20:27:52)
Mac OS X, Nvidia GPU, OpenCL 1.2, driver: 10.2.7 310.41.25f01
Could other please check their available implementations so that we can have a map of implementations that supported variadic macros?
Edit: Here is a self-contained test program that makes uses of a variadic macro.
#include <stdlib.h>
#include <stdio.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
const char* SOURCE =
"#define KERNEL(name, ...) kernel void name(__VA_ARGS__) \n"
" \n"
"KERNEL(test, global float* input, global float* output) \n"
"{ \n"
" int i = get_global_id(0); \n"
" output[i] = input[i]; \n"
"} \n"
" \n"
;
static const int GPU = 1;
int main(int argc, char** argv)
{
int err;
cl_float input[16];
cl_float output[16];
size_t global = 16;
size_t local = 16;
cl_platform_id platform_id;
cl_device_id device_id;
cl_context context;
cl_command_queue command_queue;
cl_program program;
cl_kernel kernel;
cl_mem input_buf;
cl_mem output_buf;
err = clGetPlatformIDs(1, &platform_id, NULL);
if(err != CL_SUCCESS)
{
printf("error: clGetPlatformIDs\n");
return EXIT_FAILURE;
}
err = clGetDeviceIDs(platform_id, GPU ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);
if(err != CL_SUCCESS)
{
printf("error: clGetDeviceIDs\n");
return EXIT_FAILURE;
}
context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
if(err != CL_SUCCESS)
{
printf("error: clCreateContext\n");
return EXIT_FAILURE;
}
command_queue = clCreateCommandQueue(context, device_id, 0, &err);
if(err != CL_SUCCESS)
{
printf("error: clCreateCommandQueue\n");
return EXIT_FAILURE;
}
program = clCreateProgramWithSource(context, 1, &SOURCE, NULL, &err);
if(err != CL_SUCCESS)
{
printf("error: clCreateProgramWithSource\n");
return EXIT_FAILURE;
}
err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
if (err != CL_SUCCESS)
{
size_t len;
char buffer[2048];
printf("error: clBuildProgram\n");
clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
printf("%s\n", buffer);
return EXIT_FAILURE;
}
kernel = clCreateKernel(program, "test", &err);
if(err != CL_SUCCESS)
{
printf("error: clCreateKernel\n");
return EXIT_FAILURE;
}
input_buf = clCreateBuffer(context, CL_MEM_READ_ONLY, 16*sizeof(cl_float), NULL, NULL);
output_buf = clCreateBuffer(context, CL_MEM_WRITE_ONLY, 16*sizeof(cl_float), NULL, NULL);
if(!input_buf || !output_buf)
{
printf("error: clCreateBuffer\n");
return EXIT_FAILURE;
}
err = clEnqueueWriteBuffer(command_queue, input_buf, CL_TRUE, 0, 16*sizeof(cl_float), input, 0, NULL, NULL);
if(err != CL_SUCCESS)
{
printf("error: clEnqueueWriteBuffer\n");
return EXIT_FAILURE;
}
err = 0;
err |= clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_buf);
err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_buf);
if(err != CL_SUCCESS)
{
printf("error: clSetKernelArg\n");
return EXIT_FAILURE;
}
err = clEnqueueNDRangeKernel(command_queue, kernel, 1, NULL, &global, &local, 0, NULL, NULL);
if(err != CL_SUCCESS)
{
printf("error: clEnqueueNDRangeKernel\n");
return EXIT_FAILURE;
}
clFinish(command_queue);
err = clEnqueueReadBuffer(command_queue, output_buf, CL_TRUE, 0, 16*sizeof(cl_float), output, 0, NULL, NULL );
if(err != CL_SUCCESS)
{
printf("error: clEnqueueReadBuffer\n");
return EXIT_FAILURE;
}
clReleaseMemObject(input_buf);
clReleaseMemObject(output_buf);
clReleaseProgram(program);
clReleaseKernel(kernel);
clReleaseCommandQueue(command_queue);
clReleaseContext(context);
printf("success\n");
return EXIT_SUCCESS;
}
For posterity, I will answer this myself with a list of platforms that were tested for support of variadic macros. Future visitor, please feel free to add any platform you can test to this list.
Supported:
Mac OS X, Intel CPU, OpenCL 1.2, driver: 1.1
Mac OS X, Intel GPU, OpenCL 1.2, driver: 1.2(Dec 23 2014 00:18:31)
Mac OS X, ATI GPU, OpenCL 1.2, driver: 1.2 (Aug 17 2014 20:27:52)
Debian unstable, AMD GPU, OpenCL 2.0, driver: amdgpu-pro 16.15.2-277429
Mac OS X, Nvidia GPU, OpenCL 1.2, driver: 10.2.7 310.41.25f01
Redhat Enterprise Linux 5, Nvidia CUDA SDK 4.0, OpenCL 1.0 CUDA, driver: 260.19.26
Unsupported:
Debian unstable, Intel GPU, OpenCL 1.2, driver: Beignet 1.1.1
Unsupported:
Win10 x64 2004, Intel CPU & GPU, OpenCL 2.1
Win10 x64 2004, NVIDIA GPU, OpenCL 1.2 CUDA 11.0.140

clGetDeviceIDs fails in OpenCL with error code -30

The output of the following program on my machine with ATI Firepro V8750 is as follows:
"Couldn't find any devices:No error"
(this happens at the call of first clGetDeviceIDs). the error code returned is -30. What does that mean?
I am not able to understand why it is unable to find the device. I have checked that CLinfo.exe lists my GPU along with the Intel CPU I am having. Can some one give my some pointers as to what is wrong here?
Additional info:
AMD APP SK 2.4
Firepro Driver: 8.911.3.3_VistaWin7_X32X64_135673
12-4_vista_win7_32_dd_ccc
Windows 7
Also I must mention that the firePro Driver's some componenets failed to get install.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef MAC
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
int main() {
/* Host/device data structures */
cl_platform_id platform;
cl_device_id *devices;
cl_uint num_devices, addr_data;
cl_int i, err;
/* Extension data */
char name_data[48], ext_data[4096];
/* Identify a platform */
err = clGetPlatformIDs(1, &platform, NULL);
if(err < 0) {
perror("Couldn't find any platforms");
exit(1);
}
/* Determine number of connected devices */
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, NULL, &num_devices);
if(err < 0) {
perror("Couldn't find any devices");
exit(1);
}
/* Access connected devices */
devices = (cl_device_id*)
malloc(sizeof(cl_device_id) * num_devices);
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU,
num_devices, devices, NULL);
/* Obtain data for each connected device */
for(i=0; i<num_devices; i++) {
err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME,
sizeof(name_data), name_data, NULL);
if(err < 0) {
perror("Couldn't read extension data");
exit(1);
}
clGetDeviceInfo(devices[i], CL_DEVICE_ADDRESS_BITS,
sizeof(ext_data), &addr_data, NULL);
clGetDeviceInfo(devices[i], CL_DEVICE_EXTENSIONS,
sizeof(ext_data), ext_data, NULL);
printf("NAME: %s\nADDRESS_WIDTH: %u\nEXTENSIONS: %s",
name_data, addr_data, ext_data);
}
free(devices);
return 0;
}
Here is CLINFO output:
GPU:
CPU:
Why are the two highlighted versions different?
Could it be that you have multiple OpenCL platforms installed on your system? So, perhaps your first platform is a CPU-only playform, so the query for a GPU device fails.
EDIT:
Here's the problem: The first call to clGetDeviceIDs passes 1 for num_entries, but NULL for the devices pointer. I think you want to pass in 0 for num_entries.

Resources