OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1720 Discussions

LLVM ERROR happens when compile OpenCl with pyopencl on CPU devices

msorawich
Beginner
1,936 Views

I am trying to use pyopencl to implement my kernel function on python, but I get an error when I build the OpenCL program as

"LLVM ERROR: Do not know how to split this operator's operand!".

I provide a python script below.

----------------------------------------------

import os
import itertools
import pyopencl as cl

# input file path
Example_ClFileName = 'Example.cl'

# set the environment to get the compiler output
os.environ['PYOPENCL_COMPILER_OUTPUT'] = '1'

# get all available platforms
platforms = cl.get_platforms()

# get all devices of given type
devices = list( itertools.chain.from_iterable( [ platform.get_devices( cl.device_type.CPU ) for platform in platforms ] ) )

# construct context
context = cl.Context( devices = devices )

# read the OpenCL source file as a string
with open( Example_ClFileName, 'r' ) as fileObj:
programStr = ''.join( fileObj.readlines() )

# build the opencl source file
program = cl.Program( context, programStr ).build( options = [] ) #The error happens this line

----------------------------------------------

and the OpenCL script here.

----------------------------------------------

__kernel void scaleUpElement( __global const float8* inData )
{
float8 nextRow_m1 = 0.625f * convert_float8( inData[1] );
printf( "nextRow_m1 = %f\n", nextRow_m1 );
}

----------------------------------------------

I run these scripts on 2 devices which are 12th Gen Intel(R) Core(TM) i9-12900KF and 6th Gen Intel(R) Core(TM) i7-6700K.

As a result, I can build on 6th Gen Intel(R) Core(TM) i7-6700K, but I can't build on 12th Gen Intel(R) Core(TM) i9-12900KF and get the above error.

Is there anyway to run these scripts on i9-12900KF? and Why it works on i7-6700K but does not work on i9-12900KF?

Labels (1)
0 Kudos
1 Solution
Ben_A_Intel
Employee
1,377 Views

Thank you, this output is super helpful.

It shows that you are using POCL, but a fairly old version of POCL.  Can you please try one (or both) of the following:

  1. Try the CPU OpenCL implementation from Intel, such as the version installed by the 2024.0 basekit.  This is what I used in the output above.
  2. Try updating to a newer version of POCL.  I have POCL 4.0 on my system also and it can run the tester just fine:

 

$ python3 test.py -p4
Running on platform: Portable Computing Language
Running on device: cpu-12th Gen Intel(R) Core(TM) i9-12900K
Device version: 4.0
/home/bashbaug/.local/lib/python3.10/site-packages/pyopencl/__init__.py:268: CompilerWarning: From-source build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'cpu-12th Gen Intel(R) Core(TM) i9-12900K' on 'Portable Computing Language' at 0x563f7ba91410> succeeded, but said:

warning: /home/bashbaug/.cache/pocl/kcache/tempfile_LI6yck.cl:5:34: format specifies type 'double' but the argument has type 'float8' (vector of 8 'float' values)

  warn(text, CompilerWarning)

 

There's a mismatch in the reported device in your output also that I can't quite explain ("pthread-12th Gen Intel(R) Core(TM) i9-12900KF" vs. "pthread-12th Gen Intel(R) Core(TM) i3-1215U"), but maybe this will go away with the newer version of POCL.

View solution in original post

11 Replies
cw_intel
Moderator
1,699 Views

Hi ,

 

Can you try the latest 2024.0 version ? Please download it from https://www.intel.com/content/www/us/en/developer/articles/technical/intel-cpu-runtime-for-opencl-applications-with-sycl-support.html. 

 

If you still have the same problem with the latest version on i9-12900KF, please let me know.  

 

Thanks. 

0 Kudos
msorawich
Beginner
1,621 Views

Thank you for your reply.

 

I already downloaded and installed it, but when I run the same code with pyopencl.

I still get the same error message.

 

How can I check that this version was called when I run a script ?

 

0 Kudos
cw_intel
Moderator
1,606 Views

Can you tell us the OS you used, Windows or Linux?  And can you tell us how to build your code? 

 

Thanks.

0 Kudos
msorawich
Beginner
1,573 Views

For the OS information:

I used Linux( Ubuntu 22.04) as the OS and I installed python3-pyopencl, clinfo and pocl-opencl-idc in my computer.

 

For the procedure to build my code:

I run the python script which I posted the lines of code above and then, the pyopencl in the python script build a cl kernel at runtime.

0 Kudos
cw_intel
Moderator
1,569 Views

Thank you for your feedbacks. We have tested your code on some other platforms and it works successfully. Looks like there are some issues on i9-12900KF.  We will try to find such hardware to test again. 

BTW, can you help with more testing? Can you run some other opencl codes? Then let us know if other codes can run successfully on this hardware.  
 
Can you provide us a reproducer without pyopencl?
 
 
Thanks.
 
 
0 Kudos
msorawich
Beginner
1,441 Views

I've tested running a simple kernel and it's work fine.

 

This is a script which I run for testing.

 

__kernel void sqr(__global float* input_array, __global float* output_arry)

{

    int global_id = get_global_id(0);

    output_arry[global_id] = input_array[global_id] * input_array[global_id];

}

0 Kudos
Ben_A_Intel
Employee
1,426 Views

Hi, I happen to have an i9-12900K, which isn't exactly the same as your processor but it's awfully close.

I took your pyopencl script and rewrote it slightly so it's completely self-contained.  So far I haven't been able to reproduce your OpenCL program build failure.  Could you please give this a try and let me know your output?

import pyopencl as cl
import argparse

kernelString = """
__kernel void scaleUpElement( __global const float8* inData )
{
    float8 nextRow_m1 = 0.625f * convert_float8( inData[1] );
    printf( "nextRow_m1 = %f\\n", nextRow_m1 );
}
"""

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--platform', type=int, action='store', default=0, help='Platform Index')
    parser.add_argument('-d', '--device', type=int, action='store', default=0, help='Device Index')

    args = parser.parse_args()
    platformIndex = args.platform
    deviceIndex = args.device

    platforms = cl.get_platforms()
    print('Running on platform: ' + platforms[platformIndex].name)

    devices = platforms[platformIndex].get_devices()
    print('Running on device: ' + devices[deviceIndex].name)
    print('Device version: ' + devices[deviceIndex].driver_version)

    context = cl.Context([devices[deviceIndex]])
    program = cl.Program(context, kernelString)
    program.build()

You can pick your CPU platform by passing -p and a platform number.  If you aren't sure what your CPU platform number is you can get this from `clinfo`.

Here is the output on my system.  My CPU platform happens to be platform number three, which is why I am passing -p3:

$ env | grep PYOPENCL
PYOPENCL_COMPILER_OUTPUT=1
PYOPENCL_NO_CACHE=1
$ python3 ./test.py -p3
Running on platform: Intel(R) OpenCL
Running on device: 12th Gen Intel(R) Core(TM) i9-12900K
Device version: 2023.16.10.0.17_160000
/home/bashbaug/.local/lib/python3.10/site-packages/pyopencl/__init__.py:268: CompilerWarning: From-source build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device '12th Gen Intel(R) Core(TM) i9-12900K' on 'Intel(R) OpenCL' at 0x55fb41ab4fc8> succeeded, but said:

Compilation started
1:5:34: warning: format specifies type 'double' but the argument has type 'float8' (vector of 8 'float' values)
    5 |     printf( "nextRow_m1 = %f\n", nextRow_m1 );
      |                           ~~     ^~~~~~~~~~
      |                           %v8hlf
Compilation done
Linking started
Linking done
Device build started
Options used by backend compiler: -I /home/bashbaug/.local/lib/python3.10/site-packages/pyopencl/cl
Device build done
Kernel "scaleUpElement" was successfully vectorized (8)
Done.
  warn(text, CompilerWarning)

Note, if it's helpful, this is the CPU OpenCL implementation from the 2024.0 basekit.

0 Kudos
wach_lekmanee
Beginner
1,389 Views

I've tested running your script.

 

Here the result with -p0

 

Running on platform: Portable Computing Language
Running on device: pthread-12th Gen Intel(R) Core(TM) i9-12900KF
Device version: 1.8
3 warnings generated.
/usr/lib/python3/dist-packages/pyopencl/__init__.py:264: CompilerWarning: From-source build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'pthread-12th Gen Intel(R) Core(TM) i3-1215U' on 'Portable Computing Language' at 0x5636af380650> succeeded, but said:

warning: /home/in/.cache/pocl/kcache/tempfile_5lgA2q.cl:6:34: format specifies type 'double' but the argument has type 'float8' (vector of 8 'float' values)
warning: /home/in/.cache/pocl/kcache/tempfile_5lgA2q.cl:5:34 <Spelling=/lib/x86_64-linux-gnu/../../share/pocl/include/_builtin_renames.h:718:27>: AVX vector argument of type '__private float8' (vector of 8 'float' values) without 'avx' enabled changes the ABI
warning: /home/in/.cache/pocl/kcache/tempfile_5lgA2q.cl:6:5: AVX vector argument of type 'float8' (vector of 8 'float' values) without 'avx' enabled changes the ABI

  warn(text, CompilerWarning)
LLVM ERROR: Do not know how to split this operator's operand!

Aborted (core dumped)

 

 And with -p1

 

Running on platform: NVIDIA CUDA
Running on device: NVIDIA GeForce RTX 2060 SUPER
Device version: 525.147.05

 

0 Kudos
Ben_A_Intel
Employee
1,378 Views

Thank you, this output is super helpful.

It shows that you are using POCL, but a fairly old version of POCL.  Can you please try one (or both) of the following:

  1. Try the CPU OpenCL implementation from Intel, such as the version installed by the 2024.0 basekit.  This is what I used in the output above.
  2. Try updating to a newer version of POCL.  I have POCL 4.0 on my system also and it can run the tester just fine:

 

$ python3 test.py -p4
Running on platform: Portable Computing Language
Running on device: cpu-12th Gen Intel(R) Core(TM) i9-12900K
Device version: 4.0
/home/bashbaug/.local/lib/python3.10/site-packages/pyopencl/__init__.py:268: CompilerWarning: From-source build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'cpu-12th Gen Intel(R) Core(TM) i9-12900K' on 'Portable Computing Language' at 0x563f7ba91410> succeeded, but said:

warning: /home/bashbaug/.cache/pocl/kcache/tempfile_LI6yck.cl:5:34: format specifies type 'double' but the argument has type 'float8' (vector of 8 'float' values)

  warn(text, CompilerWarning)

 

There's a mismatch in the reported device in your output also that I can't quite explain ("pthread-12th Gen Intel(R) Core(TM) i9-12900KF" vs. "pthread-12th Gen Intel(R) Core(TM) i3-1215U"), but maybe this will go away with the newer version of POCL.

msorawich
Beginner
1,316 Views

Thank you so much your solution and the script can be run completely.

0 Kudos
wach_lekmanee
Beginner
1,326 Views

I update PoCL to version 5.0 and run the script successfully.

 

Thanks!

0 Kudos
Reply