Skip to content

Commit

Permalink
Merge pull request #131 from clEsperanto/ADD--map/unmap-functionnality
Browse files Browse the repository at this point in the history
Add  map/unmap functionnality
  • Loading branch information
StRigaud authored Dec 15, 2022
2 parents 22df12c + 5a6e7de commit 0ae9c2e
Show file tree
Hide file tree
Showing 4 changed files with 377 additions and 132 deletions.
5 changes: 5 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ add_executable(benchmark_maximum_projections benchmark_maximum_projections.cpp)
target_compile_features(benchmark_maximum_projections PUBLIC cxx_std_17)
target_link_libraries(benchmark_maximum_projections benchmark_kernel)
set_target_properties(benchmark_maximum_projections PROPERTIES FOLDER "Benchmark")

add_executable(benchmark_push_pull benchmark_push_pull.cpp)
target_compile_features(benchmark_push_pull PUBLIC cxx_std_17)
target_link_libraries(benchmark_push_pull benchmark_kernel)
set_target_properties(benchmark_push_pull PROPERTIES FOLDER "Benchmark")
62 changes: 62 additions & 0 deletions benchmark/benchmark_push_pull.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <iostream>
#include <string>
#include <vector>

#include "clesperanto.hpp"

#include <benchmark_base.cpp>

class PushPullBenchmark : public BenchmarkBase
{
protected:
cle::Clesperanto cle;
std::vector<float> inputData;
std::array<size_t, 3> dim;
auto
Setup() -> void override
{
inputData = std::vector<float>(dataWidth * dataWidth * dataWidth);
dim = std::array<size_t, 3>{ { dataWidth, dataWidth, dataWidth } };

cle.GetDevice()->WaitForKernelToFinish();
}

auto
Iteration() -> void override
{
auto gpuInput = cle.Push<float>(inputData, dim);
auto output = cle.Pull<float>(gpuInput);
}

auto
Teardown() -> void override
{}

public:
size_t dataWidth = 0;

PushPullBenchmark()
: cle(cle::Clesperanto())
{}

~PushPullBenchmark() = default;
};

auto
main(int argc, char ** argv) -> int
{
PushPullBenchmark d;
d.dataWidth = 1 << 10;

d.iterationWarmupCount = 5;

if (argc >= 2)
{
d.dataWidth = std::stoi(argv[1]);
std::cout << "using " << d.dataWidth * d.dataWidth * d.dataWidth * sizeof(float) << " bytes memory" << std::endl;
}

d.Run();

return 0;
}
Loading

0 comments on commit 0ae9c2e

Please sign in to comment.