Skip to content

CUDA back-end fails with OpenCL header problems #2617

Closed
@jeffhammond

Description

@jeffhammond

I am using 69825ee:

$ git pull
Already up-to-date.
$ git branch
* sycl
$ git log -n1
commit 69825ee6cee5f0e2827ddd4b5b50fd0a5ba01cdd
Author: vladimirlaz <[email protected]>
Date:   Thu Oct 8 21:56:39 2020 +0300
...

I build like this:

$ git clean -dfx
$ /swtools/python/python-3.5.1/bin/python3 ./buildbot/configure.py --cuda  && /swtools/python/python-3.5.1/bin/python3 ./buildbot/compile.py 
args:Namespace(arm=False, base_branch=None, branch=None, build_number=None, build_type='Release', builder_dir=None, cmake_gen='Ninja', cmake_opt=None, cuda=True, docs=False, l0_headers=None, l0_loader=None, no_assertions=False, no_werror=False, obj_dir=None, pr_number=None, shared_libs=False, src_dir=None, system_ocl=False)
[Cmake Command]: cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_TARGETS_TO_BUILD=X86;NVPTX -DLLVM_EXTERNAL_PROJECTS=sycl;llvm-spirv;opencl-aot;xpti;libdevice -DLLVM_EXTERNAL_SYCL_SOURCE_DIR=~/ISYCL/llvm/sycl -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=~/ISYCL/llvm/llvm-spirv -DLLVM_EXTERNAL_XPTI_SOURCE_DIR=~/ISYCL/llvm/xpti -DLLVM_EXTERNAL_LIBDEVICE_SOURCE_DIR=~/ISYCL/llvm/libdevice -DLLVM_ENABLE_PROJECTS=clang;llvm-spirv;sycl;opencl-aot;xpti;libdevice;libclc -DLIBCLC_TARGETS_TO_BUILD=nvptx64--;nvptx64--nvidiacl -DSYCL_BUILD_PI_CUDA=ON -DLLVM_BUILD_TOOLS=ON -DSYCL_ENABLE_WERROR=ON -DCMAKE_INSTALL_PREFIX=~/ISYCL/llvm/build/install -DSYCL_INCLUDE_TESTS=ON -DLLVM_ENABLE_DOXYGEN=OFF -DLLVM_ENABLE_SPHINX=OFF -DBUILD_SHARED_LIBS=OFF -DSYCL_ENABLE_XPTI_TRACING=ON ~/ISYCL/llvm/llvm
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- The ASM compiler identification is GNU
-- Found assembler: /swtools/gcc/7.4.0/bin/gcc
-- Check for working C compiler: /swtools/gcc/7.4.0/bin/gcc
-- Check for working C compiler: /swtools/gcc/7.4.0/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /swtools/gcc/7.4.0/bin/g++
-- Check for working CXX compiler: /swtools/gcc/7.4.0/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
...
LLVM libdir: ~/ISYCL/llvm/build/./lib
LLVM bindir: ~/ISYCL/llvm/build/./bin
LLVM cxx flags: -fno-rtti;-fno-exceptions

clang: ~/ISYCL/llvm/build/./bin/clang
llvm-as: ~/ISYCL/llvm/build/./bin/llvm-as
llvm-link: ~/ISYCL/llvm/build/./bin/llvm-link
opt: ~/ISYCL/llvm/build/./bin/opt
llvm-spirv: LLVM_SPIRV-NOTFOUND

BUILDING nvptx64--
    DEVICE: none (  )
BUILDING nvptx64--nvidiacl
    DEVICE: none (  )
 Testing : nvptx64--nvidiacl
-- OpenCL_INCLUDE_DIRS is missing. Will try to download OpenCL headers from github.com
-- OpenCL_LIBRARIES is missing. Will try to download OpenCL ICD Loader from github.com
-- Including the PI API CUDA backend.
...

The tool fails like this:

/nfs_home/jrhammon/ISYCL/llvm/build/install/bin/clang++ -O3 -std=c++17 -ferror-limit=3 -fsycl -fsycl-unnamed-lambda -fsycl-targets=nvptx64-nvidia-cuda-sycldevice saxpy.cc -o saxpy.x
clang-12: warning: Unknown CUDA version 10.2. Assuming the latest supported version 10.1 [-Wunknown-cuda-version]
In file included from saxpy.cc:6:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl.hpp:11:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/ONEAPI/atomic.hpp:11:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/ONEAPI/atomic_accessor.hpp:11:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/ONEAPI/atomic_enums.hpp:12:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/access/access.hpp:10:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/detail/common.hpp:11:
/nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/cl_ext_intel.h:431:9: error: unknown type name 'cl_properties'
typedef cl_properties cl_mem_properties_intel;
        ^
In file included from saxpy.cc:6:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl.hpp:11:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/ONEAPI/atomic.hpp:11:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/ONEAPI/atomic_accessor.hpp:11:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/ONEAPI/atomic_enums.hpp:12:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/access/access.hpp:10:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/detail/common.hpp:121:
In file included from /nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/exception.hpp:15:
/nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/detail/pi.h:228:7: error: use of undeclared identifier 'CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES'
      CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
      ^
/nfs_home/jrhammon/ISYCL/llvm/build/install/bin/../include/sycl/CL/sycl/detail/pi.h:229:45: error: use of undeclared identifier 'CL_DEVICE_QUEUE_ON_HOST_PROPERTIES'
  PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES = CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
                                            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 errors generated.
make: *** [saxpy.x] Error 1

This is the source code:

#include <iostream>

#include <cmath>
#include <cfloat>

#include "CL/sycl.hpp"

namespace sycl = cl::sycl;

const float xval(1);
const float yval(2);
const float zval(2);
const float aval(3);

const float correct = (zval + aval * xval + yval);

int main(int argc, char * argv[])
{
    if (argc < 2) {
        std::cerr << "Usage: saxpy.x <vector length>" << std::endl;
        return argc;
    }

    size_t length = std::atoi(argv[1]);
    std::cout << "SAXPY with " << length << " elements" << std::endl;

    // host data
    std::vector<float> h_X(length,xval);
    std::vector<float> h_Y(length,yval);
    std::vector<float> h_Z(length,zval);

    sycl::queue q(sycl::default_selector{});

    try {

        const float A(aval);

        sycl::buffer<float,1> d_X { h_X.data(), sycl::range<1>(h_X.size()) };
        sycl::buffer<float,1> d_Y { h_Y.data(), sycl::range<1>(h_Y.size()) };
        sycl::buffer<float,1> d_Z { h_Z.data(), sycl::range<1>(h_Z.size()) };

        q.submit([&](sycl::handler& h) {

#if 0
            auto X = d_X.get_access<sycl::access::mode::read>(h);
            auto Y = d_Y.get_access<sycl::access::mode::read>(h);
            auto Z = d_Z.get_access<sycl::access::mode::read_write>(h);
#else
            sycl::accessor X(d_X,h,sycl::read_only);
            sycl::accessor Y(d_Y,h,sycl::read_only);
            sycl::accessor Z(d_Z,h,sycl::read_write);
#endif

            h.parallel_for<class axpy>( sycl::range<1>{length}, [=] (sycl::id<1> i) {
                Z[i] += A * X[i] + Y[i];
            });
        });
        q.wait();
    }
    catch (sycl::exception & e) {
        std::cout << e.what() << std::endl;
        return 1;
    }

    // check for correctness
    size_t errors(0);
    for (size_t i=0; i<length; ++i) {
        if ( std::abs(h_Z[i] - correct) > FLT_MIN) {
            ++errors;
        }
    }
    if (errors) {
        std::cerr << "There were " << errors << " errors!" << std::endl;
        for (size_t i=0; i<length; ++i) {
            std::cout << i << "," << h_Z[i] << "\n";
        }
        return 1;
    }
    std::cout << "Program completed without error." << std::endl;

    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    cudaCUDA back-end

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions