Closed
Description
Describe the bug
terminate called after throwing an instance of 'sycl::_V1::invalid_parameter_error'
what(): Index out of range -30 (PI_ERROR_INVALID_VALUE)
To Reproduce
Please describe the steps to reproduce the behavior:
These are my example code;
my example code
#include <sycl/sycl.hpp>
#include <iostream>
#include <random>
using namespace sycl;
constexpr size_t N = 10;
class RandomFiller {
public:
RandomFiller(accessor<int> ptr)
: ptr_ { ptr } {
std::random_device hwRand;
std::uniform_int_distribution<> r { 1, 100 };
randomNum_ = r(hwRand);
}
void operator()(item<1> item) const { ptr_[item.get_id()] = get_random(); }
int get_random() const { return randomNum_; }
private:
accessor<int> ptr_;
int randomNum_;
};
void workFunction(buffer<int, 1>& b, queue& q, const range<1> r) {
q.submit([&](handler& cgh) {
accessor ptr { b, cgh };
RandomFiller filler { ptr };
cgh.parallel_for(r, filler);
});
}
int main(){
queue myQueue;
auto myContext = myQueue.get_context();
auto myDev = myQueue.get_device();
range<1> r { N };
buffer<int, 1> a { r };
auto exeBundle = get_kernel_bundle<bundle_state::executable>(myContext);
std::vector<kernel_id> execKernelIds = exeBundle.get_kernel_ids();
std::cout<<"executable kernel size : "<<execKernelIds.size()<<std::endl;
for(auto kernel_id : execKernelIds){
std::cout<<"exec kernel id name : "<<kernel_id.get_name()<<std::endl;
kernel myKernel = exeBundle.get_kernel<bundle_state::executable>(kernel_id);
std::cout<<"exec kernel id info function_name : "<<myKernel.get_info<info::kernel::function_name>()<<std::endl;
std::cout<<"exec kernel id info reference count : "<<myKernel.get_info<info::kernel::reference_count>()<<std::endl;
std::cout<<"exec kernel id info num_args : "<<myKernel.get_info<info::kernel::num_args>()<<std::endl;
std::cout<<"exec kernel id info attributes : "<<myKernel.get_info<info::kernel::attributes>()<<std::endl;
std::cout<<std::endl;
}
workFunction(a,myQueue,r);
myQueue.wait();
host_accessor rand {a,read_only};
std::cout << std::endl << "Result:" << std::endl;
for (size_t i = 0; i < N; i++) {
std::cout<<"random array r["<<i<<"] = "<<r[i]<<std::endl;
// std::cout<<"B B["<<i<<"] = "<<B[i]<<std::endl;
// std::cout<<"C C["<<i<<"] = "<<C[i]<<std::endl;
// Compare the result to the analytic value
if (r[i] <= 0 || r[i] >= 100) {
std::cout << "Wrong value " << r[i] << " on element " << i << " " << std::endl;
exit(-1);
}
}
std::cout << "Good Random distribution !" << std::endl;
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
set(DPCPP_HOME "/home/wzy/sycl_workspace")
set(DPCPP_SYCL_HOME "${DPCPP_HOME}/build-cuda-2022-09-debug")
# set(DPCPP_SYCL_HOME "${DPCPP_HOME}/build-cuda-2022-09")
set(CMAKE_C_COMPILER "${DPCPP_SYCL_HOME}/bin/clang")
set(CMAKE_CXX_COMPILER "${DPCPP_SYCL_HOME}/bin/clang++")
set(CMAKE_CXX_STANDARD 17)
project(function-objects)
include_directories("${DPCPP_SYCL_HOME}/include/sycl")
include_directories("${DPCPP_SYCL_HOME}/include")
message(STATUS "dpcpp_home : ${DPCPP_HOME}")
message(STATUS "dpcpp_cuda_sycl_home : ${DPCPP_SYCL_HOME}")
message(STATUS "find library path : ${DPCPP_SYCL_HOME}/lib")
set(CMAKE_BUILD_RPATH "${DPCPP_SYCL_HOME}/lib;${CMAKE_BUILD_RPATH}")
message(STATUS "cmake build rpath : ${CMAKE_BUILD_RPATH}")
set(CMAKE_BUILD_TYPE "Debug")
# set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "-fsycl -fsycl-targets=nvptx64-nvidia-cuda")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb -std=c++17")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall -std=c++17")
link_directories("${DPCPP_SYCL_HOME}/lib")
aux_source_directory(. DIR_SRCS)
add_executable(function-objects ${DIR_SRCS})
target_include_directories(function-objects PRIVATE "${DPCPP_SYCL_HOME}/include/sycl")
target_include_directories(function-objects PRIVATE "${DPCPP_SYCL_HOME}/include")
target_link_libraries(function-objects PRIVATE sycl)
Environment (please complete the following information):
- OS: Linux
- Target device and vendor:Nvidia GPU
- DPC++ version:Clang++ 16 2022-09
- Dependencies version: cuda 11.2
Additional context
There are other problem.
1、what the mean of myKernel.get_infoinfo::kernel::num_args() ? Is parallel_for funcion object operator () arguments ?
2、why the kernel size from bundle_kernel not equals queue submit kernel size ?
Metadata
Metadata
Assignees
Labels
No labels