alpaka-group / vikunja

Vikunja is a performance portable algorithm library that defines functions operating on ranges of elements for a variety of purposes . It supports the execution on multi-core CPUs and various GPUs. Vikunja uses alpaka to implement platform-independent primitives such as reduce or transform.
https://vikunja.readthedocs.io/en/latest/
Mozilla Public License 2.0
14 stars 5 forks source link

Zip Iterator #68

Open victorjunaidy opened 2 years ago

victorjunaidy commented 2 years ago

Add:

Failed when building for accelerator testing

SimeonEhrig commented 2 years ago

Comment this line to skip the format check: https://github.com/alpaka-group/vikunja/blob/91028b1d408c773bcf6a72b2cc7830a590cc4d01/.gitlab-ci.yml#L36

SimeonEhrig commented 2 years ago

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

victorjunaidy commented 2 years ago

Sorry for the delay, finally all checks have passed

SimeonEhrig commented 2 years ago

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