-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add size function to alpaka::Vec #2416
Conversation
3161732
to
f4ff21e
Compare
f4ff21e
to
74cb39c
Compare
@@ -227,6 +227,13 @@ namespace alpaka | |||
return m_data[Dim::value - 4]; | |||
} | |||
|
|||
//! Function returns the size of the static array | |||
//! \return The size | |||
ALPAKA_FN_HOST_ACC static constexpr decltype(auto) 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.
please put an explicit return type.
I understand that the compiler can guess what it is, but the users shouldn't have to try and guess.
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.
Please copy the function signature from my PR #2415
This is the state of the art definition for C++20.
What is the different wrt #2415 ? |
Dim is not the correct name. This is a 1D static array and can be used for
any reason. (Using Dim assumes Vec is used only to define dimensions of a
grid, block or data.)
23 Eki 2024 Çar 23:28 tarihinde Andrea Bocci ***@***.***>
şunu yazdı:
… What is the different wrt #2415
<#2415> ?
—
Reply to this email directly, view it on GitHub
<#2416 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUYXIJMGBCUAXUJ42I5E3QTZ5AIGJAVCNFSM6AAAAABQPR2EXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZTGQ4TMNBVGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I disagree. We can compare std::vector data(100, 0);
std::mdspan md(data.data(), std::extents{10, 10});
// output: 100
std::cout << md.size() << "\n";
// output:
// rank 0: 10
// rank 1: 10
for(auto i = 0; i < md.rank(); ++i){
std::cout << "rank " << i << ": " << md.extent(i) << "\n";
} Also the special case Therefore is clear what is alpaka::Vec<int, alpaka::DimInt<1>> vec = {10};
std::cout << vec[0] << "\n"; // outputs the size 10
std::cout << vec.size() << "\n"; // outputs the size 10
alpaka::Vec<int, alpaka::DimInt<1>> vec2 = {10, 2};
std::cout << vec.size() << "\n"; // outputs the size 20
`` |
By the way, I don't know @mehmetyusufoglu open the same PR again and didn't ask for changing the name in my PR. |
I have not seen your PR, sorry.
Simeon Ehrig ***@***.***>, 24 Eki 2024 Per, 11:40 tarihinde
şunu yazdı:
… What is the different wrt #2415
<#2415> ?
By the way, I don't know @mehmetyusufoglu
<https://github.com/mehmetyusufoglu> open the same PR again and didn't
ask for changing the name in my PR.
—
Reply to this email directly, view it on GitHub
<#2416 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUYXIJOMODUBCSOM4ZM26DLZ5C57NAVCNFSM6AAAAABQPR2EXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZUG44DQOBXGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This PR adds a
static
function to the alpaka::Vec. It is defined static so that it can be used with the type aliases as well.