Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU OpenCL runtime: Apparent miscompilation of conditional #2038

Closed
inducer opened this issue Jul 4, 2020 · 10 comments
Closed

CPU OpenCL runtime: Apparent miscompilation of conditional #2038

inducer opened this issue Jul 4, 2020 · 10 comments
Assignees
Labels
bug Something isn't working confirmed OCL CPU Experimental RT Issues in Experimental Intel(R) CPU Runtime for OpenCL(TM) Applications with SYCL support

Comments

@inducer
Copy link

inducer commented Jul 4, 2020

Running this snippet:

import numpy as np
import pyopencl as cl
import pyopencl.array

src = """
#define lid(N) ((int) get_local_id(N))
#define gid(N) ((int) get_group_id(N))

__kernel void __attribute__ ((reqd_work_group_size(16, 1, 1))) actx_special_cos(__global double const *__restrict__ inp0, int const inp0_offset, int const n0, int const n1, __global double *__restrict__ out, int const out_offset)
{
  if (-1 * lid(0) + n1 >= 0) // CRASHES/WRONG OUTPUT ON INTEL
  //if (n1 >= lid(0))  // NO FAILURE ON INTEL
  {
      out[(1 + n1) * gid(0) + lid(0)] = cos(inp0[(1 + n1) * gid(0) + lid(0)]);
  }
}
"""


def main():
    ctx = cl._csc()
    queue = cl.CommandQueue(ctx)

    inp = cl.array.zeros(queue, (3, 4), dtype=float)
    out = cl.array.zeros_like(inp)
    prg = cl.Program(ctx, src).build()
    knl = prg.actx_special_cos
    knl(
            queue, (16*3,), (16,), inp.data, np.int32(0),
            np.int32(inp.shape[0]-1), np.int32(inp.shape[1]-1),
            out.data, np.int32(0))

    c = out.get()
    print(c)
    good = (c == 1)
    assert good.all(), np.where(good)

main()

on the CPU runtime version oclcpuexp-2020.10.6.0.4_rel distributed from this release page gives me

[[0. 0. 0. 1.]
 [1. 1. 1. 1.]
 [1. 1. 1. 1.]]
Traceback (most recent call last):
  File "testac2.py", line 38, in <module>
    main()
  File "testac2.py", line 36, in main
    assert good.all(), np.where(good)
AssertionError: (array([0, 1, 1, 1, 1, 2, 2, 2, 2]), array([3, 0, 1, 2, 3, 0, 1, 2, 3]))
double free or corruption (out)
  • Oclgrind has no complaints about this kernel.
  • Every other OpenCL implementation with which I try this kernel gives me what I'd view as the correct output:
    [[1. 1. 1. 1.]
     [1. 1. 1. 1.]
     [1. 1. 1. 1.]]
    
  • Uncommenting the (IMO) equivalent rewrite of the conditional at the top and commenting the other version makes the Intel CPU runtime behave the same as all other CL implementations.

x-ref: https://gitlab.tiker.net/inducer/meshmode/-/merge_requests/80#note_49286

@AlexeySachkov AlexeySachkov added bug Something isn't working OCL CPU Experimental RT Issues in Experimental Intel(R) CPU Runtime for OpenCL(TM) Applications with SYCL support labels Oct 13, 2020
@AlexeySachkov
Copy link
Contributor

@fzou1, @woshiyifei, @turinevgeny: FYI

@github-actions
Copy link
Contributor

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 18, 2022
@inducer
Copy link
Author

inducer commented Feb 18, 2022

I just verified that this is still an issue with release 2021-09.

@isuruf
Copy link
Contributor

isuruf commented Mar 9, 2022

@napetrov, this is an issue with the new conda package as well.

@fzou1 fzou1 self-assigned this Mar 14, 2022
@zhaomaosu
Copy link
Contributor

@inducer, thank you for reporting the issue. And the issue will be fixed in the next release of oneAPI.

@fzou1 fzou1 assigned zhaomaosu and unassigned fzou1 May 5, 2022
@inducer
Copy link
Author

inducer commented May 18, 2022

@cdai2
Copy link
Contributor

cdai2 commented May 19, 2022

The fix for this issue is already merged to code base but targeted next release. @inducer

@zhaomaosu
Copy link
Contributor

@inducer, this issue should be fixed in https://github.com/intel/llvm/releases/tag/2022-WW33. I verified locally, the case provided by you is passed now.

@inducer
Copy link
Author

inducer commented Aug 18, 2022

I can confirm that this is fixed. Thanks!

@inducer inducer closed this as completed Aug 18, 2022
@inducer
Copy link
Author

inducer commented Aug 18, 2022

Here's the next bug: #6607

jsji pushed a commit that referenced this issue Jun 8, 2023
Implement boolean function allowDecorateWithBufferLocationOrLatencyControlINTEL without a vector.

Signed-off-by: Lu, John <[email protected]>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@b97824c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed OCL CPU Experimental RT Issues in Experimental Intel(R) CPU Runtime for OpenCL(TM) Applications with SYCL support
Projects
None yet
Development

No branches or pull requests

7 participants