KhronosGroup / KhronosGroup/OpenCL-CLHPP
Creating a cl::coarse_svm_vector<> fails with all types except int on c++17 and 20
- Dominant language
- C++
- Stars
- 425
- Forks
- 133
- Avg merge
- 3h 30m
- Merged PRs (30d)
- 1
Description
Trying to allocate a vector of floats:
```
cl::SVMAllocator> svmAllocFloat;
cl::coarse_svm_vector p_vbocl(p_vbo_size, 0.0f, svmAllocFloat);
```
works fine when not setting an -std= flag when compiling (not sure what it uses then)
However when setting -std=c++17 or 20 this fails:
```
❯ clang++ basics2.cpp -lGL -lglfw -lepoxy -lOpenCL -pthread -std=c++17 -o a2-clang.out
In file included from basics2.cpp:14:
In file included from /usr/include/CL/opencl.hpp:574:
In file included from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/functional:62:
In file included from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/vector:64:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_vector.h:437:7: error: static_assert failed due to requirement 'is_same::value' "std::vector must have the same value_type as its allocator"
static_assert(is_same::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
basics2.cpp:254:34: note: in instantiation of template class 'std::vector>>' requested here
cl::coarse_svm_vector p_vbocl(p_vbo_size, 0.0f, svmAllocFloat);
^
1 error generated.
```
Specifying manually works ok:
```
cl::SVMAllocator> svmAllocFloat;
std::vector>> p_vbocl(p_vbo_size, 0.0f, svmAllocFloat);
```
From the Definition at line 3628 of file cl2.hpp:
```
3627 template < class T >
3628 using coarse_svm_vector = vector>>;
```
I guess the hard coded int should be a T?
My system cant use the TraitFine SVM so can't test it for those, but from the definition it seems to have the same problem.
Also
`cl::coarse_svm_vector test(10, 0.0f, svmAlloc);
`
just works (initializing an int array with floats?)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in cl2.hpp at the coarse_svm_vector definition around line 3628, then compare it with SVMAllocator and the manually specified std::vector type shown in the report. Reproduce the failure with clang++ under -std=c++17 or -std=c++20 using a non-int element type. Done means coarse and fine SVM vector aliases instantiate correctly for the supported element types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100