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

Adding some basic extents construction benchmark #239

Open
wants to merge 2 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function(mdspan_add_openmp_benchmark EXENAME)
endif()
endfunction()

add_subdirectory(extents)
add_subdirectory(sum)
add_subdirectory(matvec)
add_subdirectory(copy)
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/extents/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

mdspan_add_benchmark(extents_perf)
47 changes: 47 additions & 0 deletions benchmarks/extents/extents_perf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//@HEADER
// ************************************************************************
//
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//@HEADER
#include <experimental/mdspan>

#include <benchmark/benchmark.h>

#include "fill.hpp"

using index_type = int;

namespace stdex = std::experimental;
_MDSPAN_INLINE_VARIABLE constexpr auto dyn = stdex::dynamic_extent;

template <class Extents, class ... Args>
void extents_construction(benchmark::State& state, Extents, int R, Args ... args) {
for (auto _ : state) {
crtrott marked this conversation as resolved.
Show resolved Hide resolved
double val =0;
for(int r=0; r<R; r++) {
Extents ext(args...);
val += ext.extent(0);
}
if(val<1.0*R*10) std::terminate();
}
}

BENCHMARK_CAPTURE(
extents_construction, int_int_int, stdex::dextents<int,3>(), 100000000, 100, 100, 100
);

BENCHMARK_CAPTURE(
extents_construction, array_int_3, stdex::dextents<int,3>(), 100000000, std::array<int,3>{100, 100, 100}
);

BENCHMARK_MAIN();