inducer / inducer/pyopencl

Caching problem with building on CPU MacOSX Mojave ?

Open
#276 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.2k
Forks
247
Avg merge
7h 2m
Merged PRs (30d)
6

Description

Since I have update to Mojave, I get building failures on CPU device.

If I run
```import numpy as np
import pyopencl as cl

a_np = np.random.rand(50000).astype(np.float32)
b_np = np.random.rand(50000).astype(np.float32)

ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)

mf = cl.mem_flags
a_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a_np)
b_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=b_np)

prg = cl.Program(ctx, """
__kernel void sum(
__global const float *a_g, __global const float *b_g, __global float *res_g)
{
int gid = get_global_id(0);
res_g[gid] = a_g[gid] + b_g[gid];
}
""")

prg=prg.build()

res_g = cl.Buffer(ctx, mf.WRITE_ONLY, a_np.nbytes)
prg.sum(queue, a_np.shape, None, a_g, b_g, res_g)

res_np = np.empty_like(a_np)
cl.enqueue_copy(queue, res_np, res_g)

# Check on CPU with Numpy:
print(res_np - (a_np + b_np))
print(np.linalg.norm(res_np - (a_np + b_np)))
```

it works only once. Every attempt to build the same Program again will raise

```
RuntimeError: clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE

Build on :
```

If I change the kernel source, _e.g._ inserting a blank line or a comment, the build will succeed but only once. I suspect it has something to do with the caching mechanism somewhere.

Apparently related to #252, because when I run for the first time the code there, it succeeded, but now I always get the build failure.

EDIT
If some build option is added _e.g._

```
prg=prg.build(options=['-cl-opt-disable'])
```

the build will succeed once, and then will fail again. If the option is changed, it will succeed once then fail, etc.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.