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

Missing _t and _v in vector traits #63

Open
AnastasiaStulova opened this issue May 14, 2022 · 5 comments
Open

Missing _t and _v in vector traits #63

AnastasiaStulova opened this issue May 14, 2022 · 5 comments

Comments

@AnastasiaStulova
Copy link
Contributor

Some vector traits seem to be missing _t and _v versions, for example vector_size_t is missing.

@AnastasiaStulova
Copy link
Contributor Author

duplicates #60

@24spoorthi
Copy link

Hey, while trying to work on this issue, when I tried to clone the repo and compile the code, I encountered errors that was related to the opencl_type_traits.
The following was the code I tried to execute, even when there was no use of the header file error was thrown.

#include<iostream>
#include <opencl_type_traits>

using namespace std;

int main(){
        cout<<"Hello world";
        return 0;
}

The command used to execute was as follows:

clang -I include/ new.cpp

The error looked something like this:
Error on compilation

Could you please help me out with this?

@AnastasiaStulova
Copy link
Contributor Author

Clang compiles .cpp files in pure C++ mode, so to compile in C++ for OpenCL you need to use .clcpp file extension or add -cl-std=clc++.

Examples:

clang -I include/ new.clcpp
clang -cl-std=clc++ -I include/ new.cpp

I would suggest using .clcpp file extensions, however it is only supported from clang 13 onwards.

Btw iostream is not yet supported by libclcxx project so you will likely experience issues when including it in your sources.

@24spoorthi
Copy link

To get a better understanding of this issue and to confirm my understanding, these scalar_type returns a native datatype, for example,
std::scalar_type<uint8>::type will create a scalar type of the vector uint8, which is int.

Similarly, I wanted to confirm, as an example, what does scalar_type_t accept as a parameter and what does it return? Similarly, for scalar_type_v .

Are these simply an alias to scalar_type, say for example,
std::scalar_type_t<uint8_t>::type creates a scalar type of the vector uint8 which is int or is it something different?

Looking forward to hearing back.

@AnastasiaStulova
Copy link
Contributor Author

AnastasiaStulova commented Aug 10, 2022

Are these simply an alias to scalar_type, say for example,
std::scalar_type_t<uint8_t>::type creates a scalar type of the vector uint8 which is int or is it something different?

Exactly. The idea is to provide similar functionality to traits from C++17. For example remove_pointer has the following alias:

template< class T >
using remove_pointer_t = typename remove_pointer<T>::type;

which means we can use these two formats interchangeably:

std::is_same_v<int, std::remove_pointer<int*>::type>
std::is_same_v<int, std::remove_pointer_t<int*>>

Basically this is just to avoid writing ::type or ::value which makes things longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants