Skip to content

Commit

Permalink
bytes_and_flops with CMake
Browse files Browse the repository at this point in the history
Fix some warnings as well
  • Loading branch information
cedricchevalier19 committed Mar 4, 2024
1 parent e836198 commit 2773390
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 27 deletions.
1 change: 1 addition & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
KOKKOS_ADD_BENCHMARK_DIRECTORIES(bytes_and_flops)
KOKKOS_ADD_BENCHMARK_DIRECTORIES(gups)
KOKKOS_ADD_BENCHMARK_DIRECTORIES(launch_latency)
KOKKOS_ADD_BENCHMARK_DIRECTORIES(stream)
4 changes: 4 additions & 0 deletions benchmarks/bytes_and_flops/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
KOKKOS_ADD_EXECUTABLE(
bytes_and_flops
SOURCES bench_double.cpp bench_float.cpp bench_int32_t.cpp bench_int64_t.cpp main.cpp
)
12 changes: 6 additions & 6 deletions benchmarks/bytes_and_flops/bench.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ struct RunStride {
};

#define STRIDE 1
#include <bench_stride.hpp>
#include "bench_stride.hpp"
#undef STRIDE
#define STRIDE 2
#include <bench_stride.hpp>
#include "bench_stride.hpp"
#undef STRIDE
#define STRIDE 4
#include <bench_stride.hpp>
#include "bench_stride.hpp"
#undef STRIDE
#define STRIDE 8
#include <bench_stride.hpp>
#include "bench_stride.hpp"
#undef STRIDE
#define STRIDE 16
#include <bench_stride.hpp>
#include "bench_stride.hpp"
#undef STRIDE
#define STRIDE 32
#include <bench_stride.hpp>
#include "bench_stride.hpp"
#undef STRIDE

template <class Scalar>
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bytes_and_flops/bench_double.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
//@HEADER

#include <bench.hpp>
#include "bench.hpp"

template void run_stride_unroll<double>(int N, int K, int R, int D, int U,
int F, int T, int S, int B, int I);
2 changes: 1 addition & 1 deletion benchmarks/bytes_and_flops/bench_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
//@HEADER

#include <bench.hpp>
#include "bench.hpp"

template void run_stride_unroll<float>(int N, int K, int R, int D, int U, int F,
int T, int S, int B, int I);
2 changes: 1 addition & 1 deletion benchmarks/bytes_and_flops/bench_int32_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
//@HEADER

#include <bench.hpp>
#include "bench.hpp"

template void run_stride_unroll<int32_t>(int N, int K, int R, int D, int U,
int F, int T, int S, int B, int I);
2 changes: 1 addition & 1 deletion benchmarks/bytes_and_flops/bench_int64_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
//@HEADER

#include <bench.hpp>
#include "bench.hpp"

template void run_stride_unroll<int64_t>(int N, int K, int R, int D, int U,
int F, int T, int S, int B, int I);
16 changes: 8 additions & 8 deletions benchmarks/bytes_and_flops/bench_stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@
//@HEADER

#define UNROLL 1
#include <bench_unroll_stride.hpp>
#include "bench_unroll_stride.hpp"
#undef UNROLL
#define UNROLL 2
#include <bench_unroll_stride.hpp>
#include "bench_unroll_stride.hpp"
#undef UNROLL
#define UNROLL 3
#include <bench_unroll_stride.hpp>
#include "bench_unroll_stride.hpp"
#undef UNROLL
#define UNROLL 4
#include <bench_unroll_stride.hpp>
#include "bench_unroll_stride.hpp"
#undef UNROLL
#define UNROLL 5
#include <bench_unroll_stride.hpp>
#include "bench_unroll_stride.hpp"
#undef UNROLL
#define UNROLL 6
#include <bench_unroll_stride.hpp>
#include "bench_unroll_stride.hpp"
#undef UNROLL
#define UNROLL 7
#include <bench_unroll_stride.hpp>
#include "bench_unroll_stride.hpp"
#undef UNROLL
#define UNROLL 8
#include <bench_unroll_stride.hpp>
#include "bench_unroll_stride.hpp"
#undef UNROLL

template <class Scalar>
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/bytes_and_flops/bench_unroll_stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Run<Scalar, UNROLL, STRIDE> {
Kokkos::deep_copy(C, Scalar(3.5));

Kokkos::Timer timer;
for (int i = 0; i < I; ++i) {
for (int iter = 0; iter < I; ++iter) {
Kokkos::parallel_for(
"BenchmarkKernel",
Kokkos::TeamPolicy<>(N, T).set_scratch_size(0, Kokkos::PerTeam(S)),
Expand Down Expand Up @@ -87,25 +87,25 @@ struct Run<Scalar, UNROLL, STRIDE> {
C(n, i, 0) = a1;
#endif
#if (UNROLL == 2)
C(n, i, 0) = a1 + a2;
C(n, iter, 0) = a1 + a2;
#endif
#if (UNROLL == 3)
C(n, i, 0) = a1 + a2 + a3;
C(n, iter, 0) = a1 + a2 + a3;
#endif
#if (UNROLL == 4)
C(n, i, 0) = a1 + a2 + a3 + a4;
C(n, iter, 0) = a1 + a2 + a3 + a4;
#endif
#if (UNROLL == 5)
C(n, i, 0) = a1 + a2 + a3 + a4 + a5;
C(n, iter, 0) = a1 + a2 + a3 + a4 + a5;
#endif
#if (UNROLL == 6)
C(n, i, 0) = a1 + a2 + a3 + a4 + a5 + a6;
C(n, iter, 0) = a1 + a2 + a3 + a4 + a5 + a6;
#endif
#if (UNROLL == 7)
C(n, i, 0) = a1 + a2 + a3 + a4 + a5 + a6 + a7;
C(n, iter, 0) = a1 + a2 + a3 + a4 + a5 + a6 + a7;
#endif
#if (UNROLL == 8)
C(n, i, 0) = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;
C(n, iter, 0) = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;
#endif
});
}
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bytes_and_flops/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <Kokkos_Core.hpp>
#include <Kokkos_Timer.hpp>
#include <bench.hpp>
#include "bench.hpp"
#include <cstdlib>

extern template void run_stride_unroll<float>(int, int, int, int, int, int, int,
Expand Down

0 comments on commit 2773390

Please sign in to comment.