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

Zip Iterator #68

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

Conversation

victorjunaidy
Copy link

Add:

  • zip iterator
  • simple zip iterator example in host

Failed when building for accelerator testing

@SimeonEhrig
Copy link
Member

Comment this line to skip the format check:

- source $CI_PROJECT_DIR/script/check_cpp_code_style.sh

@SimeonEhrig
Copy link
Member

Please rebase on the current master. I removed C++ 14. Therefore, it is less to test.

@victorjunaidy
Copy link
Author

Sorry for the delay, finally all checks have passed

@SimeonEhrig
Copy link
Member

I see a conceptional problem in your implementation. If I understand it correctly, you pass a tuple of the begin pointers of each buffer (std::tuple<bufType1*, bufType2*, bufType3*>) to the constructor of the zip operator, which is fine. But the operator* returns the same type, which is not correct. Your operator* needs to return a tuple of single values and not the tuple of pointers. The implementation needs to be something like this:

std::tuple<bufType1, bufType2, bufType3> operator*(){
    return std::make_tuple(std::get<0>(m_iteratorTuple[m_index]), std::get<1>(m_iteratorTuple[m_index]), std::get<2>(m_iteratorTuple[index]));
}

std::tuple<bufType1, bufType2, bufType3> operator[](int i){
    return std::make_tuple(std::get<0>(m_iteratorTuple[i]), std::get<1>(m_iteratorTuple[i]), std::get<2>(m_iteratorTuple[i]));
}

I think, the main problem is to make it generic for an arbitrary number of tuple members.

I would also suggest, to test it first with deviceTransform. If you use deviceTransformReduce you have to care about the types of the functions. The return type of the transformation functor is the argument type of the reduce functor:

auto transform = [](Data1 input) -> Data2 { return static_cast<Data2>(input);};
auto reduce =  [](Data2 sum, Data2 input) -> Data2 { return sum + input;};

Also the reduce functor is restricted to a single type for the moment, see here: #52

@SimeonEhrig SimeonEhrig added this to the release 0.2 milestone Jan 19, 2022
example/zipIterator/src/zipIterator-main.cpp Outdated Show resolved Hide resolved
example/zipIterator/src/zipIterator-main.cpp Outdated Show resolved Hide resolved
example/zipIterator/src/zipIterator-main.cpp Outdated Show resolved Hide resolved
example/zipIterator/src/zipIterator-main.cpp Outdated Show resolved Hide resolved
SimeonEhrig and others added 8 commits January 27, 2022 16:42
- rename was necessary to avoid confusions with fancy iterator
- rename and flat namespace of the mem access strategy
- move related files to new folder
- now, the memory access strategy returns the index instead the actual data element
- zip iterator
- simple zip iterator example in host

Failed when building for accelerator testing
- Change transform output from fancy iterator to a memory object of std::tuple<std::uint64_t, char, double> (like the return type of the functor)
- Change transform result check by comparing element by element
- Directly use the concrete types
Update ZipIterator.hpp:
- Remove = operator
- Fix operator[]
- Change constexpr to ALPAKA_FN_HOST_ACC
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

Successfully merging this pull request may close these issues.

2 participants