From the docclass pyopencl.Program(context, devices, binaries), existing binaries can be provided to create a Program. However, this simple example fails:
import os
import pyopencl as cl
# Kernel function
src = """
__kernel void test(
__global int *a)
{
a[get_global_id(0)] = 0;
}
"""
platforms = cl.get_platforms()
for platform in platforms:
devices = platform.get_devices()
for i_device, device in enumerate(devices):
ctx = cl.Context([device])
prg = cl.Program(ctx, src).build()
binary, = prg.get_info(cl.program_info.BINARIES)
# Create Program from binary
prg1 = cl.Program(ctx, (device,), (binary,))
try:
print(prg1.all_kernels())
except cl.LogicError as e:
print(e)
From the doc
class pyopencl.Program(context, devices, binaries)
, existing binaries can be provided to create aProgram
. However, this simple example fails:The result is:
for all devices found in the platform.
MacOS 11.6.4 Big Sur, Macbook Pro. On the Windows side (BootCamp), it crashes Python.