Update Kokkos library in LAMMPS to v3.0
This commit is contained in:
@ -2,10 +2,11 @@
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
// Kokkos v. 3.0
|
||||
// Copyright (2020) National Technology & Engineering
|
||||
// Solutions of Sandia, LLC (NTESS).
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@ -23,10 +24,10 @@
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
|
||||
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
@ -41,59 +42,52 @@
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#include<Kokkos_Core.hpp>
|
||||
#include<impl/Kokkos_Timer.hpp>
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
|
||||
template<class Scalar, int Unroll,int Stride>
|
||||
template <class Scalar, int Unroll, int Stride>
|
||||
struct Run {
|
||||
static void run(int N, int K, int R, int F, int T, int S);
|
||||
static void run(int N, int K, int R, int F, int T, int S);
|
||||
};
|
||||
|
||||
template<class Scalar, int Stride>
|
||||
template <class Scalar, int Stride>
|
||||
struct RunStride {
|
||||
static void run_1(int N, int K, int R, int F, int T, int S);
|
||||
static void run_2(int N, int K, int R, int F, int T, int S);
|
||||
static void run_3(int N, int K, int R, int F, int T, int S);
|
||||
static void run_4(int N, int K, int R, int F, int T, int S);
|
||||
static void run_5(int N, int K, int R, int F, int T, int S);
|
||||
static void run_6(int N, int K, int R, int F, int T, int S);
|
||||
static void run_7(int N, int K, int R, int F, int T, int S);
|
||||
static void run_8(int N, int K, int R, int F, int T, int S);
|
||||
static void run(int N, int K, int R, int U, int F, int T, int S);
|
||||
static void run_1(int N, int K, int R, int F, int T, int S);
|
||||
static void run_2(int N, int K, int R, int F, int T, int S);
|
||||
static void run_3(int N, int K, int R, int F, int T, int S);
|
||||
static void run_4(int N, int K, int R, int F, int T, int S);
|
||||
static void run_5(int N, int K, int R, int F, int T, int S);
|
||||
static void run_6(int N, int K, int R, int F, int T, int S);
|
||||
static void run_7(int N, int K, int R, int F, int T, int S);
|
||||
static void run_8(int N, int K, int R, int F, int T, int S);
|
||||
static void run(int N, int K, int R, int U, int F, int T, int S);
|
||||
};
|
||||
|
||||
#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>
|
||||
template <class Scalar>
|
||||
void run_stride_unroll(int N, int K, int R, int D, int U, int F, int T, int S) {
|
||||
if(D == 1)
|
||||
RunStride<Scalar,1>::run(N,K,R,U,F,T,S);
|
||||
if(D == 2)
|
||||
RunStride<Scalar,2>::run(N,K,R,U,F,T,S);
|
||||
if(D == 4)
|
||||
RunStride<Scalar,4>::run(N,K,R,U,F,T,S);
|
||||
if(D == 8)
|
||||
RunStride<Scalar,8>::run(N,K,R,U,F,T,S);
|
||||
if(D == 16)
|
||||
RunStride<Scalar,16>::run(N,K,R,U,F,T,S);
|
||||
if(D == 32)
|
||||
RunStride<Scalar,32>::run(N,K,R,U,F,T,S);
|
||||
if (D == 1) RunStride<Scalar, 1>::run(N, K, R, U, F, T, S);
|
||||
if (D == 2) RunStride<Scalar, 2>::run(N, K, R, U, F, T, S);
|
||||
if (D == 4) RunStride<Scalar, 4>::run(N, K, R, U, F, T, S);
|
||||
if (D == 8) RunStride<Scalar, 8>::run(N, K, R, U, F, T, S);
|
||||
if (D == 16) RunStride<Scalar, 16>::run(N, K, R, U, F, T, S);
|
||||
if (D == 32) RunStride<Scalar, 32>::run(N, K, R, U, F, T, S);
|
||||
}
|
||||
|
||||
|
||||
@ -2,10 +2,11 @@
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
// Kokkos v. 3.0
|
||||
// Copyright (2020) National Technology & Engineering
|
||||
// Solutions of Sandia, LLC (NTESS).
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@ -23,10 +24,10 @@
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
|
||||
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
@ -41,84 +42,82 @@
|
||||
//@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>
|
||||
struct RunStride<Scalar,STRIDE> {
|
||||
static void run_1(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar,1,STRIDE>::run(N,K,R,F,T,S);
|
||||
}
|
||||
static void run_2(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar,2,STRIDE>::run(N,K,R,F,T,S);
|
||||
}
|
||||
static void run_3(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar,3,STRIDE>::run(N,K,R,F,T,S);
|
||||
}
|
||||
static void run_4(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar,4,STRIDE>::run(N,K,R,F,T,S);
|
||||
}
|
||||
static void run_5(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar,5,STRIDE>::run(N,K,R,F,T,S);
|
||||
}
|
||||
static void run_6(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar,6,STRIDE>::run(N,K,R,F,T,S);
|
||||
}
|
||||
static void run_7(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar,7,STRIDE>::run(N,K,R,F,T,S);
|
||||
}
|
||||
static void run_8(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar,8,STRIDE>::run(N,K,R,F,T,S);
|
||||
}
|
||||
template <class Scalar>
|
||||
struct RunStride<Scalar, STRIDE> {
|
||||
static void run_1(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar, 1, STRIDE>::run(N, K, R, F, T, S);
|
||||
}
|
||||
static void run_2(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar, 2, STRIDE>::run(N, K, R, F, T, S);
|
||||
}
|
||||
static void run_3(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar, 3, STRIDE>::run(N, K, R, F, T, S);
|
||||
}
|
||||
static void run_4(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar, 4, STRIDE>::run(N, K, R, F, T, S);
|
||||
}
|
||||
static void run_5(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar, 5, STRIDE>::run(N, K, R, F, T, S);
|
||||
}
|
||||
static void run_6(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar, 6, STRIDE>::run(N, K, R, F, T, S);
|
||||
}
|
||||
static void run_7(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar, 7, STRIDE>::run(N, K, R, F, T, S);
|
||||
}
|
||||
static void run_8(int N, int K, int R, int F, int T, int S) {
|
||||
Run<Scalar, 8, STRIDE>::run(N, K, R, F, T, S);
|
||||
}
|
||||
|
||||
static void run(int N, int K, int R, int U, int F, int T, int S) {
|
||||
if(U==1) {
|
||||
run_1(N,K,R,F,T,S);
|
||||
static void run(int N, int K, int R, int U, int F, int T, int S) {
|
||||
if (U == 1) {
|
||||
run_1(N, K, R, F, T, S);
|
||||
}
|
||||
if (U == 2) {
|
||||
run_2(N, K, R, F, T, S);
|
||||
}
|
||||
if (U == 3) {
|
||||
run_3(N, K, R, F, T, S);
|
||||
}
|
||||
if (U == 4) {
|
||||
run_4(N, K, R, F, T, S);
|
||||
}
|
||||
if (U == 5) {
|
||||
run_5(N, K, R, F, T, S);
|
||||
}
|
||||
if (U == 6) {
|
||||
run_6(N, K, R, F, T, S);
|
||||
}
|
||||
if (U == 7) {
|
||||
run_7(N, K, R, F, T, S);
|
||||
}
|
||||
if (U == 8) {
|
||||
run_8(N, K, R, F, T, S);
|
||||
}
|
||||
}
|
||||
if(U==2) {
|
||||
run_2(N,K,R,F,T,S);
|
||||
}
|
||||
if(U==3) {
|
||||
run_3(N,K,R,F,T,S);
|
||||
}
|
||||
if(U==4) {
|
||||
run_4(N,K,R,F,T,S);
|
||||
}
|
||||
if(U==5) {
|
||||
run_5(N,K,R,F,T,S);
|
||||
}
|
||||
if(U==6) {
|
||||
run_6(N,K,R,F,T,S);
|
||||
}
|
||||
if(U==7) {
|
||||
run_7(N,K,R,F,T,S);
|
||||
}
|
||||
if(U==8) {
|
||||
run_8(N,K,R,F,T,S);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2,10 +2,11 @@
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
// Kokkos v. 3.0
|
||||
// Copyright (2020) National Technology & Engineering
|
||||
// Solutions of Sandia, LLC (NTESS).
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@ -23,10 +24,10 @@
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
|
||||
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
@ -41,108 +42,110 @@
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
template<class Scalar>
|
||||
struct Run<Scalar,UNROLL,STRIDE> {
|
||||
static void run(int N, int K, int R, int F, int T, int S) {
|
||||
Kokkos::View<Scalar**[STRIDE],Kokkos::LayoutRight> A("A",N,K);
|
||||
Kokkos::View<Scalar**[STRIDE],Kokkos::LayoutRight> B("B",N,K);
|
||||
Kokkos::View<Scalar**[STRIDE],Kokkos::LayoutRight> C("C",N,K);
|
||||
template <class Scalar>
|
||||
struct Run<Scalar, UNROLL, STRIDE> {
|
||||
static void run(int N, int K, int R, int F, int T, int S) {
|
||||
Kokkos::View<Scalar* * [STRIDE], Kokkos::LayoutRight> A("A", N, K);
|
||||
Kokkos::View<Scalar* * [STRIDE], Kokkos::LayoutRight> B("B", N, K);
|
||||
Kokkos::View<Scalar* * [STRIDE], Kokkos::LayoutRight> C("C", N, K);
|
||||
|
||||
Kokkos::deep_copy(A,Scalar(1.5));
|
||||
Kokkos::deep_copy(B,Scalar(2.5));
|
||||
Kokkos::deep_copy(C,Scalar(3.5));
|
||||
Kokkos::deep_copy(A, Scalar(1.5));
|
||||
Kokkos::deep_copy(B, Scalar(2.5));
|
||||
Kokkos::deep_copy(C, Scalar(3.5));
|
||||
|
||||
Kokkos::Timer timer;
|
||||
Kokkos::parallel_for("BenchmarkKernel",Kokkos::TeamPolicy<>(N,T).set_scratch_size(0,Kokkos::PerTeam(S)),
|
||||
KOKKOS_LAMBDA ( const Kokkos::TeamPolicy<>::member_type& team) {
|
||||
const int n = team.league_rank();
|
||||
for(int r=0; r<R; r++) {
|
||||
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,K), [&] (const int& i) {
|
||||
Scalar a1 = A(n,i,0);
|
||||
const Scalar b = B(n,i,0);
|
||||
#if(UNROLL>1)
|
||||
Scalar a2 = a1*1.3;
|
||||
Kokkos::Timer timer;
|
||||
Kokkos::parallel_for(
|
||||
"BenchmarkKernel",
|
||||
Kokkos::TeamPolicy<>(N, T).set_scratch_size(0, Kokkos::PerTeam(S)),
|
||||
KOKKOS_LAMBDA(const Kokkos::TeamPolicy<>::member_type& team) {
|
||||
const int n = team.league_rank();
|
||||
for (int r = 0; r < R; r++) {
|
||||
Kokkos::parallel_for(
|
||||
Kokkos::TeamThreadRange(team, 0, K), [&](const int& i) {
|
||||
Scalar a1 = A(n, i, 0);
|
||||
const Scalar b = B(n, i, 0);
|
||||
#if (UNROLL > 1)
|
||||
Scalar a2 = a1 * 1.3;
|
||||
#endif
|
||||
#if(UNROLL>2)
|
||||
Scalar a3 = a2*1.1;
|
||||
#if (UNROLL > 2)
|
||||
Scalar a3 = a2 * 1.1;
|
||||
#endif
|
||||
#if(UNROLL>3)
|
||||
Scalar a4 = a3*1.1;
|
||||
#if (UNROLL > 3)
|
||||
Scalar a4 = a3 * 1.1;
|
||||
#endif
|
||||
#if(UNROLL>4)
|
||||
Scalar a5 = a4*1.3;
|
||||
#if (UNROLL > 4)
|
||||
Scalar a5 = a4 * 1.3;
|
||||
#endif
|
||||
#if(UNROLL>5)
|
||||
Scalar a6 = a5*1.1;
|
||||
#if (UNROLL > 5)
|
||||
Scalar a6 = a5 * 1.1;
|
||||
#endif
|
||||
#if(UNROLL>6)
|
||||
Scalar a7 = a6*1.1;
|
||||
#if (UNROLL > 6)
|
||||
Scalar a7 = a6 * 1.1;
|
||||
#endif
|
||||
#if(UNROLL>7)
|
||||
Scalar a8 = a7*1.1;
|
||||
#if (UNROLL > 7)
|
||||
Scalar a8 = a7 * 1.1;
|
||||
#endif
|
||||
|
||||
for (int f = 0; f < F; f++) {
|
||||
a1 += b * a1;
|
||||
#if (UNROLL > 1)
|
||||
a2 += b * a2;
|
||||
#endif
|
||||
#if (UNROLL > 2)
|
||||
a3 += b * a3;
|
||||
#endif
|
||||
#if (UNROLL > 3)
|
||||
a4 += b * a4;
|
||||
#endif
|
||||
#if (UNROLL > 4)
|
||||
a5 += b * a5;
|
||||
#endif
|
||||
#if (UNROLL > 5)
|
||||
a6 += b * a6;
|
||||
#endif
|
||||
#if (UNROLL > 6)
|
||||
a7 += b * a7;
|
||||
#endif
|
||||
#if (UNROLL > 7)
|
||||
a8 += b * a8;
|
||||
#endif
|
||||
}
|
||||
#if (UNROLL == 1)
|
||||
C(n, i, 0) = a1;
|
||||
#endif
|
||||
#if (UNROLL == 2)
|
||||
C(n, i, 0) = a1 + a2;
|
||||
#endif
|
||||
#if (UNROLL == 3)
|
||||
C(n, i, 0) = a1 + a2 + a3;
|
||||
#endif
|
||||
#if (UNROLL == 4)
|
||||
C(n, i, 0) = a1 + a2 + a3 + a4;
|
||||
#endif
|
||||
#if (UNROLL == 5)
|
||||
C(n, i, 0) = a1 + a2 + a3 + a4 + a5;
|
||||
#endif
|
||||
#if (UNROLL == 6)
|
||||
C(n, i, 0) = a1 + a2 + a3 + a4 + a5 + a6;
|
||||
#endif
|
||||
#if (UNROLL == 7)
|
||||
C(n, i, 0) = a1 + a2 + a3 + a4 + a5 + a6 + a7;
|
||||
#endif
|
||||
#if (UNROLL == 8)
|
||||
C(n, i, 0) = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;
|
||||
#endif
|
||||
});
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
double seconds = timer.seconds();
|
||||
|
||||
for(int f = 0; f<F; f++) {
|
||||
a1 += b*a1;
|
||||
#if(UNROLL>1)
|
||||
a2 += b*a2;
|
||||
#endif
|
||||
#if(UNROLL>2)
|
||||
a3 += b*a3;
|
||||
#endif
|
||||
#if(UNROLL>3)
|
||||
a4 += b*a4;
|
||||
#endif
|
||||
#if(UNROLL>4)
|
||||
a5 += b*a5;
|
||||
#endif
|
||||
#if(UNROLL>5)
|
||||
a6 += b*a6;
|
||||
#endif
|
||||
#if(UNROLL>6)
|
||||
a7 += b*a7;
|
||||
#endif
|
||||
#if(UNROLL>7)
|
||||
a8 += b*a8;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
#if(UNROLL==1)
|
||||
C(n,i,0) = a1;
|
||||
#endif
|
||||
#if(UNROLL==2)
|
||||
C(n,i,0) = a1+a2;
|
||||
#endif
|
||||
#if(UNROLL==3)
|
||||
C(n,i,0) = a1+a2+a3;
|
||||
#endif
|
||||
#if(UNROLL==4)
|
||||
C(n,i,0) = a1+a2+a3+a4;
|
||||
#endif
|
||||
#if(UNROLL==5)
|
||||
C(n,i,0) = a1+a2+a3+a4+a5;
|
||||
#endif
|
||||
#if(UNROLL==6)
|
||||
C(n,i,0) = a1+a2+a3+a4+a5+a6;
|
||||
#endif
|
||||
#if(UNROLL==7)
|
||||
C(n,i,0) = a1+a2+a3+a4+a5+a6+a7;
|
||||
#endif
|
||||
#if(UNROLL==8)
|
||||
C(n,i,0) = a1+a2+a3+a4+a5+a6+a7+a8;
|
||||
#endif
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
double seconds = timer.seconds();
|
||||
|
||||
double bytes = 1.0*N*K*R*3*sizeof(Scalar);
|
||||
double flops = 1.0*N*K*R*(F*2*UNROLL + 2*(UNROLL-1));
|
||||
printf("NKRUFTS: %i %i %i %i %i %i %i Time: %lfs Bandwidth: %lfGiB/s GFlop/s: %lf\n",N,K,R,UNROLL,F,T,S,seconds,1.0*bytes/seconds/1024/1024/1024,1.e-9*flops/seconds);
|
||||
}
|
||||
double bytes = 1.0 * N * K * R * 3 * sizeof(Scalar);
|
||||
double flops = 1.0 * N * K * R * (F * 2 * UNROLL + 2 * (UNROLL - 1));
|
||||
printf(
|
||||
"NKRUFTS: %i %i %i %i %i %i %i Time: %lfs Bandwidth: %lfGiB/s GFlop/s: "
|
||||
"%lf\n",
|
||||
N, K, R, UNROLL, F, T, S, seconds,
|
||||
1.0 * bytes / seconds / 1024 / 1024 / 1024, 1.e-9 * flops / seconds);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2,10 +2,11 @@
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
// Kokkos v. 3.0
|
||||
// Copyright (2020) National Technology & Engineering
|
||||
// Solutions of Sandia, LLC (NTESS).
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@ -23,10 +24,10 @@
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
|
||||
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
@ -41,25 +42,27 @@
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#include<Kokkos_Core.hpp>
|
||||
#include<impl/Kokkos_Timer.hpp>
|
||||
#include<bench.hpp>
|
||||
#include<cstdlib>
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
#include <bench.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
Kokkos::initialize();
|
||||
|
||||
|
||||
if(argc<10) {
|
||||
if (argc < 10) {
|
||||
printf("Arguments: N K R D U F T S\n");
|
||||
printf(" P: Precision (1==float, 2==double)\n");
|
||||
printf(" N,K: dimensions of the 2D array to allocate\n");
|
||||
printf(" R: how often to loop through the K dimension with each team\n");
|
||||
printf(" D: distance between loaded elements (stride)\n");
|
||||
printf(" U: how many independent flops to do per load\n");
|
||||
printf(" F: how many times to repeat the U unrolled operations before reading next element\n");
|
||||
printf(
|
||||
" F: how many times to repeat the U unrolled operations before "
|
||||
"reading next element\n");
|
||||
printf(" T: team size\n");
|
||||
printf(" S: shared memory per team (used to control occupancy on GPUs)\n");
|
||||
printf(
|
||||
" S: shared memory per team (used to control occupancy on GPUs)\n");
|
||||
printf("Example Input GPU:\n");
|
||||
printf(" Bandwidth Bound : 2 100000 1024 1 1 1 1 256 6000\n");
|
||||
printf(" Cache Bound : 2 100000 1024 64 1 1 1 512 20000\n");
|
||||
@ -70,7 +73,6 @@ int main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int P = atoi(argv[1]);
|
||||
int N = atoi(argv[2]);
|
||||
int K = atoi(argv[3]);
|
||||
@ -81,17 +83,25 @@ int main(int argc, char* argv[]) {
|
||||
int T = atoi(argv[8]);
|
||||
int S = atoi(argv[9]);
|
||||
|
||||
if(U>8) {printf("U must be 1-8\n"); return 0;}
|
||||
if( (D!=1) && (D!=2) && (D!=4) && (D!=8) && (D!=16) && (D!=32)) {printf("D must be one of 1,2,4,8,16,32\n"); return 0;}
|
||||
if( (P!=1) && (P!=2) ) {printf("P must be one of 1,2\n"); return 0;}
|
||||
|
||||
if(P==1) {
|
||||
run_stride_unroll<float>(N,K,R,D,U,F,T,S);
|
||||
if (U > 8) {
|
||||
printf("U must be 1-8\n");
|
||||
return 0;
|
||||
}
|
||||
if(P==2) {
|
||||
run_stride_unroll<double>(N,K,R,D,U,F,T,S);
|
||||
if ((D != 1) && (D != 2) && (D != 4) && (D != 8) && (D != 16) && (D != 32)) {
|
||||
printf("D must be one of 1,2,4,8,16,32\n");
|
||||
return 0;
|
||||
}
|
||||
if ((P != 1) && (P != 2)) {
|
||||
printf("P must be one of 1,2\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (P == 1) {
|
||||
run_stride_unroll<float>(N, K, R, D, U, F, T, S);
|
||||
}
|
||||
if (P == 2) {
|
||||
run_stride_unroll<double>(N, K, R, D, U, F, T, S);
|
||||
}
|
||||
|
||||
Kokkos::finalize();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user