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
workDivMembers construction with a user defined type #2243
workDivMembers construction with a user defined type #2243
Conversation
7a59545
to
cf88051
Compare
Rather than That would support |
include/alpaka/vec/Vec.hpp
Outdated
//! \tparam TVal is the element type of the array | ||
//! \tparam N is the size of the array | ||
template<typename TVal, size_t N> | ||
ALPAKA_FN_HOST_ACC constexpr auto arrayToVec(std::array<TVal, N> const& a) -> Vec<DimInt<N>, TVal> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for an additional method that can only handle std array.
We have the traits GetExtents
to provide the translation that alpaka can work with alpaka foreign types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I used getExtents. There is already one implemented for 1D array arguments in "ViewPlanePtr" therefore I had to check the dimension. I will refine the solution. Thanks a lot.
This may already work with #2240, if the right constructor is selected. I think |
It turns out it doesn't work, and I am not exactly sure why. The compiler fails to deduce the template parameters of the deduction guide. It has something to do with |
Yes, i also tried. Did not work.
26 Şub 2024 Pzt 21:23 tarihinde Bernhard Manfred Gruber <
***@***.***> şunu yazdı:
… That would support alpaka::WorkDivMembers{{1u, 1u}, {2u, 2u}, {1u, 1u}};.
This may already work with #2240
<#2240>, if the right
constructor is selected. I think alpaka::Vec can be created from an
initializer list.
It turns out it doesn't work, and I am not exactly sure why. The compiler
fails to deduce the template parameters of the deduction guide. It has
something to do with {1u, 1u} being an initializer list, because alpaka::WorkDivMembers{alpaka::Vec{1u,
1u}, {2u, 2u}, {1u, 1u}}; works successfully.
—
Reply to this email directly, view it on GitHub
<#2243 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUYXIJODKPJDMBYKBIDZ5YTYVTVNPAVCNFSM6AAAAABDZLEFFOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRVGE4DSMZZHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
d27f8c2
to
fc184b8
Compare
9ca42be
to
c6594df
Compare
c6594df
to
b78eb87
Compare
7e3bfa0
to
811f3f1
Compare
811f3f1
to
f64126b
Compare
9fb26bf
to
98f6601
Compare
648dd38
to
11b4b7b
Compare
Currently the following are possible due to a merged PR: I will consider your suggestion together with C++20, seems more reasonable I think. |
11b4b7b
to
0fda8d1
Compare
0fda8d1
to
d60e462
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are a few comments:
test/unit/workDiv/src/FooVec.hpp
Outdated
template<typename T, typename = void> | ||
struct has_member_arr : std::false_type | ||
{ | ||
}; | ||
|
||
template<typename T> | ||
struct has_member_arr<T, std::void_t<decltype(&T::arr)>> : std::true_type | ||
{ | ||
}; | ||
|
||
//! The DimType specialization for the user defined vector which has a member called "arr" | ||
//! \tparam T The vector type | ||
template<typename T> | ||
struct DimType<T, std::enable_if_t<has_member_arr<T>::value>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template<typename T, typename = void> | |
struct has_member_arr : std::false_type | |
{ | |
}; | |
template<typename T> | |
struct has_member_arr<T, std::void_t<decltype(&T::arr)>> : std::true_type | |
{ | |
}; | |
//! The DimType specialization for the user defined vector which has a member called "arr" | |
//! \tparam T The vector type | |
template<typename T> | |
struct DimType<T, std::enable_if_t<has_member_arr<T>::value>> | |
//! The DimType specialization for the user defined vector which has a member called "arr" | |
//! \tparam T The vector type | |
template<typename T> | |
struct DimType<FooVec> |
Why don't you just specialize for FooVec
directly? I don't see a need for SFINAE here.
Applies to other traits as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FooVec is a template, not a type. But i will try to formulate your approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad. Should be:
template<typename TVec, std::size_t Size>
struct DimType<FooVec<TVec, Size>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done thanks.
Yes, i've already did like this actually. Testing,.
Bernhard Manfred Gruber ***@***.***>, 8 Mar 2024 Cum, 13:37
tarihinde şunu yazdı:
… ***@***.**** commented on this pull request.
------------------------------
In test/unit/workDiv/src/FooVec.hpp
<#2243 (comment)>:
> + template<typename T, typename = void>
+ struct has_member_arr : std::false_type
+ {
+ };
+
+ template<typename T>
+ struct has_member_arr<T, std::void_t<decltype(&T::arr)>> : std::true_type
+ {
+ };
+
+ //! The DimType specialization for the user defined vector which has a member called "arr"
+ //! \tparam T The vector type
+ template<typename T>
+ struct DimType<T, std::enable_if_t<has_member_arr<T>::value>>
Sorry, my bad. Should be:
template<typename TVec, std::size_t Size>struct DimType<FooVec<TVec, Size>>
—
Reply to this email directly, view it on GitHub
<#2243 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUYXIJIFC3B5I64OYQ333OLYXGWKHAVCNFSM6AAAAABDZLEFFOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSMRUG44TKNZYGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
c0f798f
to
eebb62f
Compare
eebb62f
to
3c3aa6d
Compare
WorkDivMembers
class constructor could accept any vector type if the necessary traits and functions related to that type are provided.This PR uses a user-defined vector, related traits and specializations to test the of
WorkDivMembers
constructors.WorkDivMembers
construction.WorkDivMembers
construction tests are improved and refactored.WorkDivMembers
.auto const workDiv2DUsingInitList = alpaka::WorkDivMembers<Dim2D, Idx>({6, 9}, {4, 6}, {1, 1});
initializes 3 alpaka vectors as arguments.