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

Minimal broadcasting engine for c++ #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

serge-sans-paille
Copy link

This is somehow simpler (but probably less generic) than @wolfv solution. Probably a good starter before eating wolv's one :-)

@oxinabox
Copy link

Yes,
I had big hopes for templating.

@SimonDanisch
Copy link
Owner

Pretty cool :) I'll look into it in more detail!

@SimonDanisch
Copy link
Owner

Maybe we can develop an interface for the C++ solutions:
benchmark.cpp:

#include "solution.cpp"
extern "C" 
{
  void benchmark_broadcast(){
    auto op = make_lazy([](auto& out, auto x, auto y, auto z) { out = x + y - std::sin(z); });
    materialize(op)
  }
  void benchmark_sum(){
    ...
  }
}

Not sure if we should generate the elements in benchmark, have globals, or pass them to the function. The advantage would be, that we very easily could benchmark this from Julia with the exact same benchmarking library ;)
cc @wolfv

@SimonDanisch
Copy link
Owner

And I would have access to the benchmark code in a more orderly manner ;)

@wolfv
Copy link
Contributor

wolfv commented Sep 25, 2018

Well, that will generate a bunch of questions though.

For example, if we pass pointers to the interface, C++ can't be sure that they don't alias so not all optimizations can be enabled an these kind of things. However, benchmarking the creation as well will require me to write more code (as we'll need to use a uninitialized vector type) and this kind of stuff.

We might be able to develop an interface which initializes a couple of global C++ arrays, and then calls functions without parameters to bench.

Also, I think this might be a bit overkill. I think the minimal time for one iteration gives a good indication of the quality of the generated code.

@SimonDanisch
Copy link
Owner

We might be able to develop an interface which initializes a couple of global C++ arrays, and then calls functions without parameters to bench.

Sounds good ;)

Also, I think this might be a bit overkill. I think the minimal time for one iteration gives a good indication of the quality of the generated code.

Yeah I guess ... I may, or may not, want to use the minimal C interface to further play around with it, though :P
Anyways, it was just an idea to organize the code for me to immediately see what get's benchmarked... So putting the different benchmarks in their own function might be a good organization anyways.

@serge-sans-paille
Copy link
Author

@SimonDanisch please tell me updated if you need more things in that example. I didn't add benchmark because there is no native 2D array in C++...

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.

4 participants