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

Added tests for existing math operators #828

Closed
wants to merge 3 commits into from

Conversation

jkrude
Copy link
Contributor

@jkrude jkrude commented Aug 23, 2019

Tested StdLib-backend fully.
Tested Cuda-backend compiling.
Not tested Hip-backend.
Edit: Refractored Code according to https://github.com/ComputationalRadiationPhysics/contributing/blob/master/codingGuideLines/cpp.md.

Copy link
Member

@psychocoderHPC psychocoderHPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first PR. Only a few small changes are required

@BenjaminW3 BenjaminW3 removed this from the Version 0.4.0 milestone Aug 23, 2019
@BenjaminW3
Copy link
Member

All the build jobs complain about some compilation issues. Are you working on it?

@tdd11235813
Copy link
Contributor

tdd11235813 commented Sep 11, 2019

Actually I do not really like the code because of the functions pointers (it is also not working).
When talked about a solution in the first time, we had arrays in mind to describe the set of functions.
The function pointers' host-device interoperability actually would require more dirty code (example) and it becomes more and more ugly and it is better to remake it in a good and functional C++ style now :)
(Edit: this is not the fault of @jkrude, I just did not have enough time to think about good design)

I discussed with @psychocoderHPC again, and that I like the simple row-wise-like enumeration of the related math functions+range.
Functors would be more easy to handle for host-device compiling, we just need a way to compact code, so one does not have to write dozens of functor boilerplate codes.

// sketching a possible functor layout for math test
struct TestOpFoo {
  static constexpr Range range = Range::Unrestricted;
  static constexpr OpType optype = OpType::Unary;

  ALPAKA_FN_ACC
  template<typename T>
  auto operator() ( T arg1 ) -> T {
     return alpaka::math::foo( arg1 );
  }

  ALPAKA_FN_HOST
  template<typename T>
  auto expect( T arg1 ) -> T {
     return std::foo(arg1);
  }
};

// creating a tuple with all the Ops, passing it to single kernel
// OR using a compile-time foreach, invoking a kernel for each functor 
...

Then for each math function a functor has to be written and registered for the test kernel. Just need a clean way to compact functors and their processing ...

Btw, code-style should be discussed, too ( eg. curly braces for initialization, except for elemental types, where assignment is ok, like in for-loops ).

Edits: typo + edit after 1st paragraph

@tdd11235813
Copy link
Contributor

re-written and pushed in #847 separately, so closing this.

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

Successfully merging this pull request may close these issues.

5 participants