diff --git a/CHANGELOG.md b/CHANGELOG.md index 0584776..dc28185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. ### Removed - Superfluous OpenMP 4.5 map(to:) clauses on kernel target regions. - Kokkos namespace not used by default so the API is easier to spot. +- Manual specification of Kokkos layout (DEVICE) as the Kokkos library sets this by default. ### Fixed - Kokkos now compiles and links separately to fix complication with Kokkos 2.05.00. diff --git a/Kokkos.make b/Kokkos.make index 8935121..306348f 100644 --- a/Kokkos.make +++ b/Kokkos.make @@ -29,20 +29,17 @@ $(info $(target_help)) TARGET=CPU endif -ifeq ($(TARGET), CPU) -TARGET_DEF = -DKOKKOS_TARGET_CPU -else ifeq ($(TARGET), GPU) +ifeq ($(TARGET), GPU) CXX = $(NVCC_WRAPPER) -TARGET_DEF = endif OBJ = main.o KokkosStream.o kokkos-stream: $(OBJ) $(KOKKOS_CPP_DEPENDS) - $(CXX) $(KOKKOS_LDFLAGS) $(KOKKOS_LIBS) -DKOKKOS $(TARGET_DEF) -O3 $(EXTRA_FLAGS) $(OBJ) -o $@ + $(CXX) $(KOKKOS_LDFLAGS) $(KOKKOS_LIBS) -DKOKKOS -O3 $(EXTRA_FLAGS) $(OBJ) -o $@ %.o: %.cpp - $(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) -DKOKKOS $(TARGET_DEF) -O3 $(EXTRA_FLAGS) -c $< + $(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) -DKOKKOS -O3 $(EXTRA_FLAGS) -c $< .PHONY: clean clean: diff --git a/KokkosStream.cpp b/KokkosStream.cpp index 41588ec..39e4775 100644 --- a/KokkosStream.cpp +++ b/KokkosStream.cpp @@ -14,12 +14,12 @@ KokkosStream::KokkosStream( { Kokkos::initialize(); - d_a = new Kokkos::View("d_a", ARRAY_SIZE); - d_b = new Kokkos::View("d_b", ARRAY_SIZE); - d_c = new Kokkos::View("d_c", ARRAY_SIZE); - hm_a = new Kokkos::View::HostMirror(); - hm_b = new Kokkos::View::HostMirror(); - hm_c = new Kokkos::View::HostMirror(); + d_a = new Kokkos::View("d_a", ARRAY_SIZE); + d_b = new Kokkos::View("d_b", ARRAY_SIZE); + d_c = new Kokkos::View("d_c", ARRAY_SIZE); + hm_a = new Kokkos::View::HostMirror(); + hm_b = new Kokkos::View::HostMirror(); + hm_c = new Kokkos::View::HostMirror(); *hm_a = create_mirror_view(*d_a); *hm_b = create_mirror_view(*d_b); *hm_c = create_mirror_view(*d_c); @@ -34,9 +34,9 @@ KokkosStream::~KokkosStream() template void KokkosStream::init_arrays(T initA, T initB, T initC) { - Kokkos::View a(*d_a); - Kokkos::View b(*d_b); - Kokkos::View c(*d_c); + Kokkos::View a(*d_a); + Kokkos::View b(*d_b); + Kokkos::View c(*d_c); Kokkos::parallel_for(array_size, KOKKOS_LAMBDA (const long index) { a[index] = initA; @@ -64,9 +64,9 @@ void KokkosStream::read_arrays( template void KokkosStream::copy() { - Kokkos::View a(*d_a); - Kokkos::View b(*d_b); - Kokkos::View c(*d_c); + Kokkos::View a(*d_a); + Kokkos::View b(*d_b); + Kokkos::View c(*d_c); Kokkos::parallel_for(array_size, KOKKOS_LAMBDA (const long index) { @@ -78,9 +78,9 @@ void KokkosStream::copy() template void KokkosStream::mul() { - Kokkos::View a(*d_a); - Kokkos::View b(*d_b); - Kokkos::View c(*d_c); + Kokkos::View a(*d_a); + Kokkos::View b(*d_b); + Kokkos::View c(*d_c); const T scalar = startScalar; Kokkos::parallel_for(array_size, KOKKOS_LAMBDA (const long index) @@ -93,9 +93,9 @@ void KokkosStream::mul() template void KokkosStream::add() { - Kokkos::View a(*d_a); - Kokkos::View b(*d_b); - Kokkos::View c(*d_c); + Kokkos::View a(*d_a); + Kokkos::View b(*d_b); + Kokkos::View c(*d_c); Kokkos::parallel_for(array_size, KOKKOS_LAMBDA (const long index) { @@ -107,9 +107,9 @@ void KokkosStream::add() template void KokkosStream::triad() { - Kokkos::View a(*d_a); - Kokkos::View b(*d_b); - Kokkos::View c(*d_c); + Kokkos::View a(*d_a); + Kokkos::View b(*d_b); + Kokkos::View c(*d_c); const T scalar = startScalar; Kokkos::parallel_for(array_size, KOKKOS_LAMBDA (const long index) @@ -122,8 +122,8 @@ void KokkosStream::triad() template T KokkosStream::dot() { - Kokkos::View a(*d_a); - Kokkos::View b(*d_b); + Kokkos::View a(*d_a); + Kokkos::View b(*d_b); T sum = 0.0; diff --git a/KokkosStream.hpp b/KokkosStream.hpp index ac88cdf..9ba6fea 100644 --- a/KokkosStream.hpp +++ b/KokkosStream.hpp @@ -17,12 +17,6 @@ #define IMPLEMENTATION_STRING "Kokkos" -#ifdef KOKKOS_TARGET_CPU - #define DEVICE Kokkos::OpenMP -#else - #define DEVICE Kokkos::Cuda -#endif - template class KokkosStream : public Stream { @@ -31,9 +25,9 @@ class KokkosStream : public Stream unsigned int array_size; // Device side pointers to arrays - Kokkos::View* d_a; - Kokkos::View* d_b; - Kokkos::View* d_c; + Kokkos::View* d_a; + Kokkos::View* d_b; + Kokkos::View* d_c; Kokkos::View::HostMirror* hm_a; Kokkos::View::HostMirror* hm_b; Kokkos::View::HostMirror* hm_c;