Skip to content

[SYCL] LLVM ERROR: OCL version mismatch while building test application #3

Closed

Description

@kpet

Building the simple test application using the 1-step flow results in the following behaviour:

$ ./bin/clang++ -std=c++11 -fsycl -I/path/to/OpenCL-Headers/ simple-sycl-app.cpp -o simple-sycl-app -lsycl  /path/to/opencllib.so
LLVM ERROR: OCL version mismatch
/tmp/simple-sycl-app-e14b6d.o: file not recognised: File truncated
clang-8: error: sycl-link command failed with exit code 1 (use -v to see invocation)
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

FYI /path/to/opencllib.so contains a version of the SPIRV-LLVM translator.

With the following hack:

--- a/llvm-spirv/lib/SPIRV/OCLUtil.cpp
+++ b/llvm-spirv/lib/SPIRV/OCLUtil.cpp
@@ -231,11 +231,14 @@ unsigned getOCLVersion(Module *M, bool AllowMulti) {
     return std::make_pair(getMDOperandAsInt(MD, 0), getMDOperandAsInt(MD, 1));
   };
   auto Ver = GetVer(0);
+#if 0
   for (unsigned I = 1, E = NamedMD->getNumOperands(); I != E; ++I)
     if (Ver != GetVer(I))
       report_fatal_error("OCL version mismatch");
-
   return encodeOCLVer(Ver.first, Ver.second, 0);
+#else
+  return encodeOCLVer(2, 1, 0);
+#endif
 }

 void decodeMDNode(MDNode *N, unsigned &X, unsigned &Y, unsigned &Z) {

the build succeeds.

Activity

  1. bader commented on Jan 24, 2019

    @bader
    Contributor

    Could try to link with the library with -L -l options, please?

    We are working on alternative solution I hope we will upload a fix soon. The problem here is LLVM-SPIR-V translator which create a non-empty LLVM module from an empty SPIR-V file (I assume opencllib.so doesn't have SPIR-V code). This non-empty LLVM module has OpenCL 1.2 version encoded in metadata and the check you disabled, detects that we are trying to link SPIR-V files built from OpenCL C++ and OpenCL 1.2, which makes it fail.

  2. kpet commented on Jan 24, 2019

    @kpet
    ContributorAuthor

    Using -L -l just works and that's probably what I should have used anyway.

  3. self-assigned this
    on Feb 11, 2019
  4. bader commented on Feb 12, 2019

    @bader
    Contributor

    Should be fixed by PR #23.

  5. added a commit that references this issue on Mar 7, 2019
  6. wangliwei-intel commented on Mar 27, 2019

    @wangliwei-intel

    @bader
    When I ran sample code, I got this result:
    The result is incorrect for element: 1 , expected: 1 , got: 0
    The result is incorrect for element: 2 , expected: 2 , got: 0
    The result is incorrect for element: 3 , expected: 3 , got: 0

    Platform Info:
    HW: KabyLake
    SW: Ubutu 16.04.x
    OpenCL: 2.1 (Verified by some code written by myself, it's ok.)

    Did I do something wrong? Can you give me some hints on this?
    Thank you.

  7. 244 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions