Updating kokkos lib
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14918 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -1,10 +0,0 @@
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# This is a tutorial, not a test, so we don't ask CTest to run it.
|
||||
TRIBITS_ADD_EXECUTABLE(
|
||||
tutorial_advancedviews_01_data_layouts
|
||||
SOURCES data_layouts.cpp
|
||||
COMM serial mpi
|
||||
)
|
||||
@ -1,43 +0,0 @@
|
||||
KOKKOS_PATH = ../../../..
|
||||
SRC = $(wildcard *.cpp)
|
||||
|
||||
default: build
|
||||
echo "Start Build"
|
||||
|
||||
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))
|
||||
CXX = nvcc_wrapper
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.cuda)
|
||||
KOKKOS_DEVICES = "Cuda,OpenMP"
|
||||
KOKKOS_ARCH = "SNB,Kepler35"
|
||||
else
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.host)
|
||||
KOKKOS_DEVICES = "OpenMP"
|
||||
KOKKOS_ARCH = "SNB"
|
||||
endif
|
||||
|
||||
DEPFLAGS = -M
|
||||
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
LIB =
|
||||
|
||||
include $(KOKKOS_PATH)/Makefile.kokkos
|
||||
|
||||
build: $(EXE)
|
||||
|
||||
$(EXE): $(OBJ) $(KOKKOS_LINK_DEPENDS)
|
||||
$(LINK) $(KOKKOS_LDFLAGS) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(KOKKOS_LIBS) $(LIB) -o $(EXE)
|
||||
|
||||
clean: kokkos-clean
|
||||
rm -f *.o *.cuda *.host
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp $(KOKKOS_CPP_DEPENDS)
|
||||
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<
|
||||
@ -1,171 +0,0 @@
|
||||
/*
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the Corporation nor the names of the
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
|
||||
//
|
||||
// ************************************************************************
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
// These two View types are both 2-D arrays of double. However, they
|
||||
// have different layouts in memory. left_type has "layout left,"
|
||||
// which means "column major," the same as in Fortran, the BLAS, or
|
||||
// LAPACK. right_type has "layout right," which means "row major,"
|
||||
// the same as in C, C++, or Java.
|
||||
typedef Kokkos::View<double**, Kokkos::LayoutLeft> left_type;
|
||||
typedef Kokkos::View<double**, Kokkos::LayoutRight> right_type;
|
||||
// This is a one-dimensional View, so the layout matters less.
|
||||
// However, it still has a layout! Since its layout is not specified
|
||||
// explicitly in the type, its layout is a function of the memory
|
||||
// space. For example, the default Cuda layout is LayoutLeft, and the
|
||||
// default Host layout is LayoutRight.
|
||||
typedef Kokkos::View<double*> view_type;
|
||||
|
||||
// parallel_for functor that fills the given View with some data. It
|
||||
// expects to access the View by rows in parallel: each call i of
|
||||
// operator() accesses a row.
|
||||
template<class ViewType>
|
||||
struct init_view {
|
||||
ViewType a;
|
||||
init_view (ViewType a_) : a (a_) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const typename ViewType::size_type i) const {
|
||||
// On CPUs this loop could be vectorized so j should do stride 1
|
||||
// access on a for optimal performance. I.e. a should be LayoutRight.
|
||||
// On GPUs threads should do coalesced loads and stores. That means
|
||||
// that i should be the stride one access for optimal performance.
|
||||
for (typename ViewType::size_type j = 0; j < a.dimension_1 (); ++j) {
|
||||
a(i,j) = 1.0*a.dimension_0()*i + 1.0*j;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Compute a contraction of v1 and v2 into a:
|
||||
//
|
||||
// a(i) := sum_j (v1(i,j) * v2(j,i))
|
||||
//
|
||||
// Since the functor is templated on the ViewTypes itself it doesn't matter what
|
||||
// there layouts are. That means you can use different layouts on different
|
||||
// architectures.
|
||||
template<class ViewType1, class ViewType2>
|
||||
struct contraction {
|
||||
view_type a;
|
||||
typename ViewType1::const_type v1;
|
||||
typename ViewType2::const_type v2;
|
||||
contraction (view_type a_, ViewType1 v1_, ViewType2 v2_) :
|
||||
a (a_), v1 (v1_), v2 (v2_)
|
||||
{}
|
||||
|
||||
// As with the initialization functor the performance of this operator
|
||||
// depends on the architecture and the chosen data layouts.
|
||||
// On CPUs optimal would be to vectorize the inner loop, so j should be the
|
||||
// stride 1 access. That means v1 should be LayoutRight and v2 LayoutLeft.
|
||||
// In order to get coalesced access on GPUs where i corresponds closely to
|
||||
// the thread Index, i must be the stride 1 dimension. That means v1 should be
|
||||
// LayoutLeft and v2 LayoutRight.
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const view_type::size_type i) const {
|
||||
for (view_type::size_type j = 0; j < v1.dimension_1 (); ++j) {
|
||||
a(i) = v1(i,j)*v2(j,i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Compute a dot product. This is used for result verification.
|
||||
struct dot {
|
||||
view_type a;
|
||||
dot (view_type a_) : a (a_) {}
|
||||
typedef double value_type; //Specify type for reduction target, lsum
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const view_type::size_type i, double &lsum) const {
|
||||
lsum += a(i)*a(i);
|
||||
}
|
||||
};
|
||||
|
||||
int main (int narg, char* arg[]) {
|
||||
// When initializing Kokkos, you may pass in command-line arguments,
|
||||
// just like with MPI_Init(). Kokkos reserves the right to remove
|
||||
// arguments from the list that start with '--kokkos-'.
|
||||
Kokkos::initialize (narg, arg);
|
||||
|
||||
int size = 10000;
|
||||
view_type a("A",size);
|
||||
|
||||
// Define two views with LayoutLeft and LayoutRight.
|
||||
left_type l("L",size,10000);
|
||||
right_type r("R",size,10000);
|
||||
|
||||
// Initialize the data in the views.
|
||||
Kokkos::parallel_for(size,init_view<left_type>(l));
|
||||
Kokkos::parallel_for(size,init_view<right_type>(r));
|
||||
Kokkos::fence();
|
||||
|
||||
// Measure time to execute the contraction kernel when giving it a
|
||||
// LayoutLeft view for v1 and a LayoutRight view for v2. This should be
|
||||
// fast on GPUs and slow on CPUs
|
||||
Kokkos::Impl::Timer time1;
|
||||
Kokkos::parallel_for(size,contraction<left_type,right_type>(a,l,r));
|
||||
Kokkos::fence();
|
||||
double sec1 = time1.seconds();
|
||||
|
||||
double sum1 = 0;
|
||||
Kokkos::parallel_reduce(size,dot(a),sum1);
|
||||
Kokkos::fence();
|
||||
|
||||
// Measure time to execute the contraction kernel when giving it a
|
||||
// LayoutRight view for v1 and a LayoutLeft view for v2. This should be
|
||||
// fast on CPUs and slow on GPUs
|
||||
Kokkos::Impl::Timer time2;
|
||||
Kokkos::parallel_for(size,contraction<right_type,left_type>(a,r,l));
|
||||
Kokkos::fence();
|
||||
double sec2 = time2.seconds();
|
||||
|
||||
double sum2 = 0;
|
||||
Kokkos::parallel_reduce(size,dot(a),sum2);
|
||||
|
||||
// Kokkos' reductions are deterministic.
|
||||
// The results should always be equal.
|
||||
printf("Result Left/Right %f Right/Left %f (equal result: %i)\n",sec1,sec2,sum2==sum1);
|
||||
|
||||
Kokkos::finalize();
|
||||
}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# This is a tutorial, not a test, so we don't ask CTest to run it.
|
||||
TRIBITS_ADD_EXECUTABLE(
|
||||
tutorial_advancedviews_02_memory_traits
|
||||
SOURCES memory_traits.cpp
|
||||
COMM serial mpi
|
||||
)
|
||||
@ -1,43 +0,0 @@
|
||||
KOKKOS_PATH = ../../../..
|
||||
SRC = $(wildcard *.cpp)
|
||||
|
||||
default: build
|
||||
echo "Start Build"
|
||||
|
||||
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))
|
||||
CXX = nvcc_wrapper
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.cuda)
|
||||
KOKKOS_DEVICES = "Cuda,OpenMP"
|
||||
KOKKOS_ARCH = "SNB,Kepler35"
|
||||
else
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.host)
|
||||
KOKKOS_DEVICES = "OpenMP"
|
||||
KOKKOS_ARCH = "SNB"
|
||||
endif
|
||||
|
||||
DEPFLAGS = -M
|
||||
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
LIB =
|
||||
|
||||
include $(KOKKOS_PATH)/Makefile.kokkos
|
||||
|
||||
build: $(EXE)
|
||||
|
||||
$(EXE): $(OBJ) $(KOKKOS_LINK_DEPENDS)
|
||||
$(LINK) $(KOKKOS_LDFLAGS) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(KOKKOS_LIBS) $(LIB) -o $(EXE)
|
||||
|
||||
clean: kokkos-clean
|
||||
rm -f *.o *.cuda *.host
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp $(KOKKOS_CPP_DEPENDS)
|
||||
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<
|
||||
@ -1,141 +0,0 @@
|
||||
/*
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the Corporation nor the names of the
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
|
||||
//
|
||||
// ************************************************************************
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
typedef Kokkos::View<double*> view_type;
|
||||
// Kokkos::Views have an MemoryTraits template parameter which
|
||||
// allows users to specify usage scenarios of a View.
|
||||
// Some of those act simply as hints, which can be used to insert
|
||||
// optimal load and store paths, others change the symantics of the
|
||||
// access. The trait Kokkos::Atomic is one of the latter. A view with
|
||||
// that MemoryTrait will perform any access atomicly (read, write, update).
|
||||
//
|
||||
// In this example we use a view with a usage hint for RandomAccess.
|
||||
// Kokkos::RandomAccess means that we expect to use this view
|
||||
// with indirect indexing.
|
||||
//
|
||||
// In CUDA, RandomAccess allows accesses through the texture
|
||||
// cache. This only works if the View is read-only, which we enforce
|
||||
// through the first template parameter.
|
||||
//
|
||||
// Note that we are still talking about views of the data, its not a new allocation.
|
||||
// For example you can have an atomic view of a default view. While you even
|
||||
// could use both in the same kernel, this could lead to undefined behaviour because
|
||||
// one of your access paths is not atomic. Think of it in the same way as you think of
|
||||
// pointers to const data and pointers to non-const data (i.e. const double* and double*).
|
||||
// While these pointers can point to the same data you should not use them together if that
|
||||
// brakes the const guarantee of the first pointer.
|
||||
typedef Kokkos::View<const double*, Kokkos::MemoryTraits<Kokkos::RandomAccess> > view_type_rnd;
|
||||
typedef Kokkos::View<int**> idx_type;
|
||||
typedef idx_type::HostMirror idx_type_host;
|
||||
|
||||
// We template this functor on the ViewTypes to show the effect of the RandomAccess trait.
|
||||
template<class DestType, class SrcType>
|
||||
struct localsum {
|
||||
idx_type::const_type idx;
|
||||
DestType dest;
|
||||
SrcType src;
|
||||
localsum (idx_type idx_, DestType dest_, SrcType src_) :
|
||||
idx (idx_), dest (dest_), src (src_)
|
||||
{}
|
||||
|
||||
// Calculate a local sum of values
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const int i) const {
|
||||
double tmp = 0.0;
|
||||
for (int j = 0; j < (int) idx.dimension_1 (); ++j) {
|
||||
// This is an indirect access on src
|
||||
const double val = src(idx(i,j));
|
||||
tmp += val*val + 0.5*(idx.dimension_0()*val -idx.dimension_1()*val);
|
||||
}
|
||||
dest(i) = tmp;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int narg, char* arg[]) {
|
||||
Kokkos::initialize (narg, arg);
|
||||
|
||||
int size = 1000000;
|
||||
|
||||
idx_type idx("Idx",size,64);
|
||||
idx_type_host h_idx = Kokkos::create_mirror_view (idx);
|
||||
|
||||
view_type dest ("Dest", size);
|
||||
view_type src ("Src", size);
|
||||
|
||||
srand(134231);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (view_type::size_type j = 0; j < h_idx.dimension_1 (); ++j) {
|
||||
h_idx(i,j) = (size + i + (rand () % 500 - 250)) % size;
|
||||
}
|
||||
}
|
||||
|
||||
// Deep copy the initial data to the device
|
||||
Kokkos::deep_copy(idx,h_idx);
|
||||
// Run the first kernel to warmup caches
|
||||
Kokkos::parallel_for(size,localsum<view_type,view_type_rnd>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
|
||||
// Run the localsum functor using the RandomAccess trait. On CPUs there should
|
||||
// not be any different in performance to not using the RandomAccess trait.
|
||||
// On GPUs where can be a dramatic difference
|
||||
Kokkos::Impl::Timer time1;
|
||||
Kokkos::parallel_for(size,localsum<view_type,view_type_rnd>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec1 = time1.seconds();
|
||||
|
||||
Kokkos::Impl::Timer time2;
|
||||
Kokkos::parallel_for(size,localsum<view_type,view_type>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec2 = time2.seconds();
|
||||
|
||||
printf("Time with Trait RandomAccess: %f with Plain: %f \n",sec1,sec2);
|
||||
|
||||
Kokkos::finalize();
|
||||
}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# This is a tutorial, not a test, so we don't ask CTest to run it.
|
||||
TRIBITS_ADD_EXECUTABLE(
|
||||
tutorial_advancedviews_03_subviews
|
||||
SOURCES subviews.cpp
|
||||
COMM serial mpi
|
||||
)
|
||||
@ -1,43 +0,0 @@
|
||||
KOKKOS_PATH = ../../../..
|
||||
SRC = $(wildcard *.cpp)
|
||||
|
||||
default: build
|
||||
echo "Start Build"
|
||||
|
||||
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))
|
||||
CXX = nvcc_wrapper
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.cuda)
|
||||
KOKKOS_DEVICES = "Cuda,OpenMP"
|
||||
KOKKOS_ARCH = "SNB,Kepler35"
|
||||
else
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.host)
|
||||
KOKKOS_DEVICES = "OpenMP"
|
||||
KOKKOS_ARCH = "SNB"
|
||||
endif
|
||||
|
||||
DEPFLAGS = -M
|
||||
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
LIB =
|
||||
|
||||
include $(KOKKOS_PATH)/Makefile.kokkos
|
||||
|
||||
build: $(EXE)
|
||||
|
||||
$(EXE): $(OBJ) $(KOKKOS_LINK_DEPENDS)
|
||||
$(LINK) $(KOKKOS_LDFLAGS) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(KOKKOS_LIBS) $(LIB) -o $(EXE)
|
||||
|
||||
clean: kokkos-clean
|
||||
rm -f *.o *.cuda *.host
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp $(KOKKOS_CPP_DEPENDS)
|
||||
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<
|
||||
@ -1,190 +0,0 @@
|
||||
/*
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the Corporation nor the names of the
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
|
||||
//
|
||||
// ************************************************************************
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
// This example simulates one timestep of an explicit
|
||||
// finite-difference discretization of a time-dependent partial
|
||||
// differential equation (PDE). It shows how to take subviews of the
|
||||
// mesh in order to represent particular boundaries or the interior of
|
||||
// the mesh.
|
||||
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
typedef Kokkos::View<double***, Kokkos::LayoutRight> mesh_type;
|
||||
|
||||
// These View types represent subviews of the mesh. Some of the Views
|
||||
// have layout LayoutStride, meaning that they have run-time "strides"
|
||||
// in each dimension which may differ from that dimension. For
|
||||
// example, inner_mesh_type (which represents the interior of the
|
||||
// mesh) has to skip over the boundaries when computing its stride;
|
||||
// the dimensions of the interior mesh differ from these strides. You
|
||||
// may safely always use a LayoutStride layout when taking a subview
|
||||
// of a LayoutRight or LayoutLeft subview, but strided accesses may
|
||||
// cost a bit more, especially for 1-D Views.
|
||||
typedef Kokkos::View<double**, Kokkos::LayoutStride> xz_plane_type;
|
||||
typedef Kokkos::View<double**, Kokkos::LayoutRight> yz_plane_type;
|
||||
typedef Kokkos::View<double**, Kokkos::LayoutStride> xy_plane_type;
|
||||
typedef Kokkos::View<double***, Kokkos::LayoutStride> inner_mesh_type;
|
||||
|
||||
// Functor to set all entries of a boundary of the mesh to a constant
|
||||
// value. The functor is templated on ViewType because different
|
||||
// boundaries may have different layouts.
|
||||
template<class ViewType>
|
||||
struct set_boundary {
|
||||
ViewType a;
|
||||
double value;
|
||||
|
||||
set_boundary (ViewType a_, double value_) :
|
||||
a (a_), value (value_)
|
||||
{}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const typename ViewType::size_type i) const {
|
||||
for (typename ViewType::size_type j = 0; j < a.dimension_1 (); ++j) {
|
||||
a(i,j) = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Functor to set all entries of a boundary of the mesh to a constant
|
||||
// value. The functor is templated on ViewType because different
|
||||
// boundaries may have different layouts.
|
||||
template<class ViewType>
|
||||
struct set_inner {
|
||||
ViewType a;
|
||||
double value;
|
||||
|
||||
set_inner (ViewType a_, double value_) :
|
||||
a (a_), value (value_)
|
||||
{}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator () (const typename ViewType::size_type i) const {
|
||||
typedef typename ViewType::size_type size_type;
|
||||
for (size_type j = 0; j < a.dimension_1 (); ++j) {
|
||||
for (size_type k = 0; k < a.dimension_2 (); ++k) {
|
||||
a(i,j,k) = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Update the interior of the mesh. This simulates one timestep of a
|
||||
// finite-difference method.
|
||||
template<class ViewType>
|
||||
struct update {
|
||||
ViewType a;
|
||||
const double dt;
|
||||
|
||||
update (ViewType a_, const double dt_) :
|
||||
a (a_), dt (dt_)
|
||||
{}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (typename ViewType::size_type i) const {
|
||||
typedef typename ViewType::size_type size_type;
|
||||
i++;
|
||||
for (size_type j = 1; j < a.dimension_1()-1; j++) {
|
||||
for (size_type k = 1; k < a.dimension_2()-1; k++) {
|
||||
a(i,j,k) += dt* (a(i,j,k+1) - a(i,j,k-1) +
|
||||
a(i,j+1,k) - a(i,j-1,k) +
|
||||
a(i+1,j,k) - a(i-1,j,k));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main (int narg, char* arg[]) {
|
||||
using Kokkos::ALL;
|
||||
using Kokkos::pair;
|
||||
using Kokkos::parallel_for;
|
||||
using Kokkos::subview;
|
||||
typedef mesh_type::size_type size_type;
|
||||
|
||||
Kokkos::initialize (narg, arg);
|
||||
|
||||
// The number of mesh points along each dimension of the mesh, not
|
||||
// including boundaries.
|
||||
const size_type size = 100;
|
||||
|
||||
// A is the full cubic 3-D mesh, including the boundaries.
|
||||
mesh_type A ("A", size+2, size+2, size+2);
|
||||
// Ai is the "inner" part of A, _not_ including the boundaries.
|
||||
//
|
||||
// A pair of indices in a particular dimension means the contiguous
|
||||
// zero-based index range in that dimension, including the first
|
||||
// entry of the pair but _not_ including the second entry.
|
||||
inner_mesh_type Ai = subview(A, pair<size_type, size_type> (1, size+1),
|
||||
pair<size_type, size_type> (1, size+1),
|
||||
pair<size_type, size_type> (1, size+1));
|
||||
// A has six boundaries, one for each face of the cube.
|
||||
// Create a View of each of these boundaries.
|
||||
// ALL() means "select all indices in that dimension."
|
||||
xy_plane_type Zneg_halo = subview(A, ALL (), ALL (), 0);
|
||||
xy_plane_type Zpos_halo = subview(A, ALL (), ALL (), 101);
|
||||
xz_plane_type Yneg_halo = subview(A, ALL (), 0, ALL ());
|
||||
xz_plane_type Ypos_halo = subview(A, ALL (), 101, ALL ());
|
||||
yz_plane_type Xneg_halo = subview(A, 0, ALL (), ALL ());
|
||||
yz_plane_type Xpos_halo = subview(A, 101, ALL (), ALL ());
|
||||
|
||||
// Set the boundaries to their initial conditions.
|
||||
parallel_for (Zneg_halo.dimension_0 (), set_boundary<xy_plane_type> (Zneg_halo, 1));
|
||||
parallel_for (Zpos_halo.dimension_0 (), set_boundary<xy_plane_type> (Zpos_halo, -1));
|
||||
parallel_for (Yneg_halo.dimension_0 (), set_boundary<xz_plane_type> (Yneg_halo, 2));
|
||||
parallel_for (Ypos_halo.dimension_0 (), set_boundary<xz_plane_type> (Ypos_halo, -2));
|
||||
parallel_for (Xneg_halo.dimension_0 (), set_boundary<yz_plane_type> (Xneg_halo, 3));
|
||||
parallel_for (Xpos_halo.dimension_0 (), set_boundary<yz_plane_type> (Xpos_halo, -3));
|
||||
|
||||
// Set the interior of the mesh to its initial condition.
|
||||
parallel_for (Ai.dimension_0 (), set_inner<inner_mesh_type> (Ai, 0));
|
||||
|
||||
// Update the interior of the mesh.
|
||||
// This simulates one timestep with dt = 0.1.
|
||||
parallel_for (Ai.dimension_0 (), update<mesh_type> (A, 0.1));
|
||||
|
||||
printf ("Done\n");
|
||||
Kokkos::finalize ();
|
||||
}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# This is a tutorial, not a test, so we don't ask CTest to run it.
|
||||
TRIBITS_ADD_EXECUTABLE(
|
||||
tutorial_advancedviews_04_dualviews
|
||||
SOURCES dual_view.cpp
|
||||
COMM serial mpi
|
||||
)
|
||||
@ -1,43 +0,0 @@
|
||||
KOKKOS_PATH = ../../../..
|
||||
SRC = $(wildcard *.cpp)
|
||||
|
||||
default: build
|
||||
echo "Start Build"
|
||||
|
||||
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))
|
||||
CXX = nvcc_wrapper
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.cuda)
|
||||
KOKKOS_DEVICES = "Cuda,OpenMP"
|
||||
KOKKOS_ARCH = "SNB,Kepler35"
|
||||
else
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.host)
|
||||
KOKKOS_DEVICES = "OpenMP"
|
||||
KOKKOS_ARCH = "SNB"
|
||||
endif
|
||||
|
||||
DEPFLAGS = -M
|
||||
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
LIB =
|
||||
|
||||
include $(KOKKOS_PATH)/Makefile.kokkos
|
||||
|
||||
build: $(EXE)
|
||||
|
||||
$(EXE): $(OBJ) $(KOKKOS_LINK_DEPENDS)
|
||||
$(LINK) $(KOKKOS_LDFLAGS) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(KOKKOS_LIBS) $(LIB) -o $(EXE)
|
||||
|
||||
clean: kokkos-clean
|
||||
rm -f *.o *.cuda *.host
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp $(KOKKOS_CPP_DEPENDS)
|
||||
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<
|
||||
@ -1,214 +0,0 @@
|
||||
/*
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the Corporation nor the names of the
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
|
||||
//
|
||||
// ************************************************************************
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <Kokkos_DualView.hpp>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
// DualView helps you manage data and computations that take place on
|
||||
// two different memory spaces. Examples include CUDA device memory
|
||||
// and (CPU) host memory (currently implemented), or Intel Knights
|
||||
// Landing MCDRAM and DRAM (not yet implemented). For example, if you
|
||||
// have ported only some parts of you application to run in CUDA,
|
||||
// DualView can help manage moving data between the parts of your
|
||||
// application that work best with CUDA, and the parts that work
|
||||
// better on the CPU.
|
||||
//
|
||||
// A DualView takes the same template parameters as a View, but
|
||||
// contains two Views: One that lives in the DualView's memory space,
|
||||
// and one that lives in that memory space's host mirror space. If
|
||||
// both memory spaces are the same, then the two Views just alias one
|
||||
// another. This means that you can use DualView all the time, even
|
||||
// when not running in a memory space like CUDA. DualView's
|
||||
// operations to help you manage memory take almost no time in that
|
||||
// case. This makes your code even more performance portable.
|
||||
|
||||
typedef Kokkos::DualView<double*> view_type;
|
||||
typedef Kokkos::DualView<int**> idx_type;
|
||||
|
||||
|
||||
template<class ExecutionSpace>
|
||||
struct localsum {
|
||||
// If the functor has a public 'execution_space' typedef, that defines
|
||||
// the functor's execution space (where it runs in parallel). This
|
||||
// overrides Kokkos' default execution space.
|
||||
typedef ExecutionSpace execution_space;
|
||||
|
||||
typedef typename Kokkos::Impl::if_c<Kokkos::Impl::is_same<ExecutionSpace,Kokkos::DefaultExecutionSpace>::value ,
|
||||
idx_type::memory_space, idx_type::host_mirror_space>::type memory_space;
|
||||
|
||||
// Get the view types on the particular device for which the functor
|
||||
// is instantiated.
|
||||
//
|
||||
// "const_data_type" is a typedef in View (and DualView) which is
|
||||
// the const version of the first template parameter of the View.
|
||||
// For example, the const_data_type version of double** is const
|
||||
// double**.
|
||||
Kokkos::View<idx_type::const_data_type, idx_type::array_layout, memory_space> idx;
|
||||
// "array_intrinsic_type" is a typedef in ViewTraits (and DualView) which is the
|
||||
// array version of the value(s) stored in the View.
|
||||
Kokkos::View<view_type::array_intrinsic_type, view_type::array_layout, memory_space> dest;
|
||||
Kokkos::View<view_type::const_data_type, view_type::array_layout,
|
||||
memory_space, Kokkos::MemoryRandomAccess> src;
|
||||
|
||||
// Constructor takes DualViews, synchronizes them to the device,
|
||||
// then marks them as modified on the device.
|
||||
localsum (idx_type dv_idx, view_type dv_dest, view_type dv_src)
|
||||
{
|
||||
// Extract the view on the correct Device (i.e., the correct
|
||||
// memory space) from the DualView. DualView has a template
|
||||
// method, view(), which is templated on the memory space. If the
|
||||
// DualView has a View from that memory space, view() returns the
|
||||
// View in that space.
|
||||
idx = dv_idx.view<memory_space> ();
|
||||
dest = dv_dest.template view<memory_space> ();
|
||||
src = dv_src.template view<memory_space> ();
|
||||
|
||||
// Synchronize the DualView to the correct Device.
|
||||
//
|
||||
// DualView's sync() method is templated on a memory space, and
|
||||
// synchronizes the DualView in a one-way fashion to that memory
|
||||
// space. "Synchronizing" means copying, from the other memory
|
||||
// space to the Device memory space. sync() does _nothing_ if the
|
||||
// Views on the two memory spaces are in sync. DualView
|
||||
// determines this by the user manually marking one side or the
|
||||
// other as modified; see the modify() call below.
|
||||
|
||||
dv_idx.sync<memory_space> ();
|
||||
dv_dest.template sync<memory_space> ();
|
||||
dv_src.template sync<memory_space> ();
|
||||
|
||||
// Mark dest as modified on Device.
|
||||
dv_dest.template modify<memory_space> ();
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const int i) const {
|
||||
double tmp = 0.0;
|
||||
for (int j = 0; j < (int) idx.dimension_1(); ++j) {
|
||||
const double val = src(idx(i,j));
|
||||
tmp += val*val + 0.5*(idx.dimension_0()*val -idx.dimension_1()*val);
|
||||
}
|
||||
dest(i) += tmp;
|
||||
}
|
||||
};
|
||||
|
||||
class ParticleType {
|
||||
public:
|
||||
double q;
|
||||
double m;
|
||||
double q_over_m;
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
ParticleType(double q_ = -1, double m_ = 1):
|
||||
q(q_), m(m_), q_over_m(q/m) {}
|
||||
protected:
|
||||
};
|
||||
|
||||
typedef Kokkos::DualView<ParticleType[10]> ParticleTypes;
|
||||
int main (int narg, char* arg[]) {
|
||||
Kokkos::initialize (narg, arg);
|
||||
|
||||
ParticleTypes test("Test");
|
||||
Kokkos::fence();
|
||||
test.h_view(0) = ParticleType(-1e4,1);
|
||||
Kokkos::fence();
|
||||
|
||||
int size = 1000000;
|
||||
|
||||
// Create DualViews. This will allocate on both the device and its
|
||||
// host_mirror_device.
|
||||
idx_type idx ("Idx",size,64);
|
||||
view_type dest ("Dest",size);
|
||||
view_type src ("Src",size);
|
||||
|
||||
|
||||
srand (134231);
|
||||
|
||||
// Get a reference to the host view of idx directly (equivalent to
|
||||
// idx.view<idx_type::host_mirror_space>() )
|
||||
idx_type::t_host h_idx = idx.h_view;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
for (view_type::size_type j = 0; j < h_idx.dimension_1 (); ++j) {
|
||||
h_idx(i,j) = (size + i + (rand () % 500 - 250)) % size;
|
||||
}
|
||||
}
|
||||
|
||||
// Mark idx as modified on the host_mirror_space so that a
|
||||
// sync to the device will actually move data. The sync happens in
|
||||
// the functor's constructor.
|
||||
idx.modify<idx_type::host_mirror_space> ();
|
||||
|
||||
// Run on the device. This will cause a sync of idx to the device,
|
||||
// since it was marked as modified on the host.
|
||||
Kokkos::Impl::Timer timer;
|
||||
Kokkos::parallel_for(size,localsum<view_type::execution_space>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec1_dev = timer.seconds();
|
||||
|
||||
timer.reset();
|
||||
Kokkos::parallel_for(size,localsum<view_type::execution_space>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec2_dev = timer.seconds();
|
||||
|
||||
// Run on the host's default execution space (could be the same as device).
|
||||
// This will cause a sync back to the host of dest. Note that if the Device is CUDA,
|
||||
// the data layout will not be optimal on host, so performance is
|
||||
// lower than what it would be for a pure host compilation.
|
||||
timer.reset();
|
||||
Kokkos::parallel_for(size,localsum<Kokkos::HostSpace::execution_space>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec1_host = timer.seconds();
|
||||
|
||||
timer.reset();
|
||||
Kokkos::parallel_for(size,localsum<Kokkos::HostSpace::execution_space>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec2_host = timer.seconds();
|
||||
|
||||
printf("Device Time with Sync: %f without Sync: %f \n",sec1_dev,sec2_dev);
|
||||
printf("Host Time with Sync: %f without Sync: %f \n",sec1_host,sec2_host);
|
||||
|
||||
Kokkos::finalize();
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
IF (Kokkos_ENABLE_Cuda_UVM)
|
||||
# This is a tutorial, not a test, so we don't ask CTest to run it.
|
||||
TRIBITS_ADD_EXECUTABLE(
|
||||
tutorial_advancedviews_05_nvidia_uvm
|
||||
SOURCES uvm_example.cpp
|
||||
COMM serial mpi
|
||||
DEPLIBS kokkoscontainers kokkoscore
|
||||
)
|
||||
ENDIF ()
|
||||
@ -1,43 +0,0 @@
|
||||
KOKKOS_PATH = ../../../..
|
||||
SRC = $(wildcard *.cpp)
|
||||
|
||||
default: build
|
||||
echo "Start Build"
|
||||
|
||||
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))
|
||||
CXX = nvcc_wrapper
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.cuda)
|
||||
KOKKOS_DEVICES = "Cuda,OpenMP"
|
||||
KOKKOS_ARCH = "SNB,Kepler35"
|
||||
else
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.host)
|
||||
KOKKOS_DEVICES = "OpenMP"
|
||||
KOKKOS_ARCH = "SNB"
|
||||
endif
|
||||
|
||||
DEPFLAGS = -M
|
||||
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
LIB =
|
||||
|
||||
include $(KOKKOS_PATH)/Makefile.kokkos
|
||||
|
||||
build: $(EXE)
|
||||
|
||||
$(EXE): $(OBJ) $(KOKKOS_LINK_DEPENDS)
|
||||
$(LINK) $(KOKKOS_LDFLAGS) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(KOKKOS_LIBS) $(LIB) -o $(EXE)
|
||||
|
||||
clean: kokkos-clean
|
||||
rm -f *.o *.cuda *.host
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp $(KOKKOS_CPP_DEPENDS)
|
||||
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<
|
||||
@ -1,134 +0,0 @@
|
||||
/*
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the Corporation nor the names of the
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
|
||||
//
|
||||
// ************************************************************************
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <Kokkos_DualView.hpp>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
typedef Kokkos::View<double*> view_type;
|
||||
typedef Kokkos::View<int**> idx_type;
|
||||
|
||||
|
||||
template<class Device>
|
||||
struct localsum {
|
||||
// Define the execution space for the functor (overrides the DefaultExecutionSpace)
|
||||
typedef Device execution_space;
|
||||
|
||||
// Get the view types on the particular device the functor is instantiated for
|
||||
idx_type::const_type idx;
|
||||
view_type dest;
|
||||
Kokkos::View<view_type::const_data_type, view_type::array_layout, view_type::execution_space, Kokkos::MemoryRandomAccess > src;
|
||||
|
||||
localsum(idx_type idx_, view_type dest_,
|
||||
view_type src_):idx(idx_),dest(dest_),src(src_) {
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (int i) const {
|
||||
double tmp = 0.0;
|
||||
for(int j = 0; j < idx.dimension_1(); j++) {
|
||||
const double val = src(idx(i,j));
|
||||
tmp += val*val + 0.5*(idx.dimension_0()*val -idx.dimension_1()*val);
|
||||
}
|
||||
dest(i) += tmp;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int narg, char* arg[]) {
|
||||
Kokkos::initialize(narg,arg);
|
||||
|
||||
int size = 1000000;
|
||||
|
||||
// Create Views
|
||||
idx_type idx("Idx",size,64);
|
||||
view_type dest("Dest",size);
|
||||
view_type src("Src",size);
|
||||
|
||||
srand(134231);
|
||||
|
||||
// When using UVM Cuda views can be accessed on the Host directly
|
||||
for(int i=0; i<size; i++) {
|
||||
for(int j=0; j<idx.dimension_1(); j++)
|
||||
idx(i,j) = (size + i + (rand()%500 - 250))%size;
|
||||
}
|
||||
|
||||
Kokkos::fence();
|
||||
// Run on the device
|
||||
// This will cause a sync of idx to the device since it was modified on the host
|
||||
Kokkos::Impl::Timer timer;
|
||||
Kokkos::parallel_for(size,localsum<view_type::execution_space>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec1_dev = timer.seconds();
|
||||
|
||||
// No data transfer will happen now, since nothing is accessed on the host
|
||||
timer.reset();
|
||||
Kokkos::parallel_for(size,localsum<view_type::execution_space>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec2_dev = timer.seconds();
|
||||
|
||||
// Run on the host
|
||||
// This will cause a sync back to the host of dest which was changed on the device
|
||||
// Compare runtime here with the dual_view example: dest will be copied back in 4k blocks
|
||||
// when they are accessed the first time during the parallel_for. Due to the latency of a memcpy
|
||||
// this gives lower effective bandwidth when doing a manual copy via dual views
|
||||
timer.reset();
|
||||
Kokkos::parallel_for(size,localsum<Kokkos::HostSpace::execution_space>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec1_host = timer.seconds();
|
||||
|
||||
// No data transfers will happen now
|
||||
timer.reset();
|
||||
Kokkos::parallel_for(size,localsum<Kokkos::HostSpace::execution_space>(idx,dest,src));
|
||||
Kokkos::fence();
|
||||
double sec2_host = timer.seconds();
|
||||
|
||||
|
||||
|
||||
printf("Device Time with Sync: %lf without Sync: %lf \n",sec1_dev,sec2_dev);
|
||||
printf("Host Time with Sync: %lf without Sync: %lf \n",sec1_host,sec2_host);
|
||||
|
||||
Kokkos::finalize();
|
||||
}
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
KOKKOS_PATH = ../../../..
|
||||
SRC = $(wildcard *.cpp)
|
||||
|
||||
default: build
|
||||
echo "Start Build"
|
||||
|
||||
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))
|
||||
CXX = nvcc_wrapper
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.cuda)
|
||||
KOKKOS_DEVICES = "Cuda,OpenMP"
|
||||
KOKKOS_ARCH = "SNB,Kepler35"
|
||||
else
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.host)
|
||||
KOKKOS_DEVICES = "OpenMP"
|
||||
KOKKOS_ARCH = "SNB"
|
||||
endif
|
||||
|
||||
DEPFLAGS = -M
|
||||
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
LIB =
|
||||
|
||||
include $(KOKKOS_PATH)/Makefile.kokkos
|
||||
|
||||
build: $(EXE)
|
||||
|
||||
$(EXE): $(OBJ) $(KOKKOS_LINK_DEPENDS)
|
||||
$(LINK) $(KOKKOS_LDFLAGS) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(KOKKOS_LIBS) $(LIB) -o $(EXE)
|
||||
|
||||
clean: kokkos-clean
|
||||
rm -f *.o *.cuda *.host
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp $(KOKKOS_CPP_DEPENDS)
|
||||
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<
|
||||
@ -1,43 +0,0 @@
|
||||
KOKKOS_PATH = ../../../..
|
||||
SRC = $(wildcard *.cpp)
|
||||
|
||||
default: build
|
||||
echo "Start Build"
|
||||
|
||||
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))
|
||||
CXX = nvcc_wrapper
|
||||
CXXFLAGS = -O3 --default-stream per-thread
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.cuda)
|
||||
KOKKOS_DEVICES = "Cuda,OpenMP"
|
||||
KOKKOS_ARCH = "SNB,Kepler35"
|
||||
else
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3
|
||||
LINK = ${CXX}
|
||||
LINKFLAGS =
|
||||
EXE = $(SRC:.cpp=.host)
|
||||
KOKKOS_DEVICES = "OpenMP"
|
||||
KOKKOS_ARCH = "SNB"
|
||||
endif
|
||||
|
||||
DEPFLAGS = -M
|
||||
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
LIB =
|
||||
|
||||
include $(KOKKOS_PATH)/Makefile.kokkos
|
||||
|
||||
build: $(EXE)
|
||||
|
||||
$(EXE): $(OBJ) $(KOKKOS_LINK_DEPENDS)
|
||||
$(LINK) $(KOKKOS_LDFLAGS) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(KOKKOS_LIBS) $(LIB) -o $(EXE)
|
||||
|
||||
clean: kokkos-clean
|
||||
rm -f *.o *.cuda *.host
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp $(KOKKOS_CPP_DEPENDS)
|
||||
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<
|
||||
@ -1,148 +0,0 @@
|
||||
/*
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the Corporation nor the names of the
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
|
||||
//
|
||||
// ************************************************************************
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <cstdio>
|
||||
#include <typeinfo>
|
||||
#include <cmath>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
|
||||
struct FillDevice {
|
||||
double value;
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace> a;
|
||||
FillDevice(const double& val, const Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace>& d_a):
|
||||
value(val),a(d_a){}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const int& i) const {
|
||||
a(i) = value;
|
||||
}
|
||||
};
|
||||
|
||||
struct ComputeADevice {
|
||||
int iter;
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace> a;
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace> b;
|
||||
ComputeADevice(const int& iter_,
|
||||
const Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace>& d_a,
|
||||
const Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace>& d_b):
|
||||
iter(iter_),a(d_a),b(d_b){}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const int& i) const {
|
||||
for(int j=1;j<iter;j++) {
|
||||
a(i) += std::pow(b(i),1.0+1.0/iter);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct ComputeAHost {
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaHostPinnedSpace> a;
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaHostPinnedSpace> b;
|
||||
ComputeAHost( const Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaHostPinnedSpace>& d_a,
|
||||
const Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaHostPinnedSpace>& d_b):
|
||||
a(d_a),b(d_b){}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const int& i) const {
|
||||
a(i) += b(i);
|
||||
}
|
||||
};
|
||||
|
||||
struct MergeDevice {
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace> a;
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace> b;
|
||||
MergeDevice(
|
||||
const Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace>& d_a,
|
||||
const Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace>& d_b):
|
||||
a(d_a),b(d_b){}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (const int& i) const {
|
||||
a(i) += b(i);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
int size = 100000000;
|
||||
Kokkos::initialize();
|
||||
int synch = atoi(argv[1]);
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace> d_a("Device A",size);
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace> d_b("Device B",size);
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaSpace> d_tmp("Device tmp",size);
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaHostPinnedSpace> h_a("Host A",size);
|
||||
Kokkos::View<double*,Kokkos::LayoutLeft,Kokkos::CudaHostPinnedSpace> h_b("Host B",size);
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::Cuda>(0,size),FillDevice(0.0,d_a));
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::Cuda>(0,size),FillDevice(1.3513,d_b));
|
||||
Kokkos::fence();
|
||||
Kokkos::Impl::Timer timer;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::Cuda>(0,size),ComputeADevice(20,d_a,d_b));
|
||||
|
||||
if(synch==1)
|
||||
Kokkos::deep_copy(Kokkos::OpenMP(),h_b,d_b);
|
||||
if(synch==2)
|
||||
Kokkos::deep_copy(h_b,d_b);
|
||||
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::OpenMP>(0,size),[=] (const int& i) {
|
||||
h_a(i) = 0.0;
|
||||
});
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::OpenMP>(0,size),ComputeAHost(h_a,h_b));
|
||||
Kokkos::OpenMP::fence();
|
||||
if(synch==1)
|
||||
Kokkos::deep_copy(Kokkos::OpenMP(), d_tmp,h_a);
|
||||
if(synch==2)
|
||||
Kokkos::deep_copy(d_tmp,h_a);
|
||||
Kokkos::fence();
|
||||
|
||||
std::cout << "Time " << timer.seconds() << std::endl;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::Cuda>(0,size),MergeDevice(d_a,d_tmp));
|
||||
|
||||
Kokkos::deep_copy(h_a,d_a);
|
||||
std::cout << "h_a(0): " << h_a(0) << " ( Correct: 27.4154 )" << std::endl;
|
||||
Kokkos::finalize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
|
||||
TRIBITS_ADD_EXAMPLE_DIRECTORIES(01_data_layouts)
|
||||
TRIBITS_ADD_EXAMPLE_DIRECTORIES(02_memory_traits)
|
||||
TRIBITS_ADD_EXAMPLE_DIRECTORIES(03_subviews)
|
||||
TRIBITS_ADD_EXAMPLE_DIRECTORIES(04_dualviews)
|
||||
|
||||
IF (Kokkos_ENABLE_Cuda_UVM)
|
||||
TRIBITS_ADD_EXAMPLE_DIRECTORIES(05_NVIDIA_UVM)
|
||||
ENDIF ()
|
||||
@ -1,84 +0,0 @@
|
||||
default:
|
||||
cd ./01_data_layouts; \
|
||||
make -j 4
|
||||
cd ./02_memory_traits; \
|
||||
make -j 4
|
||||
cd ./03_subviews; \
|
||||
make -j 4
|
||||
cd ./04_dualviews; \
|
||||
make -j 4
|
||||
cd ./05_NVIDIA_UVM; \
|
||||
make -j 4
|
||||
cd ./06_AtomicViews; \
|
||||
make -j 4
|
||||
|
||||
openmp:
|
||||
cd ./01_data_layouts; \
|
||||
make -j 4 KOKKOS_DEVICES=OpenMP
|
||||
cd ./02_memory_traits; \
|
||||
make -j 4 KOKKOS_DEVICES=OpenMP
|
||||
cd ./03_subviews; \
|
||||
make -j 4 KOKKOS_DEVICES=OpenMP
|
||||
cd ./04_dualviews; \
|
||||
make -j 4 KOKKOS_DEVICES=OpenMP
|
||||
cd ./05_NVIDIA_UVM; \
|
||||
make -j 4 KOKKOS_DEVICES=OpenMP
|
||||
cd ./06_AtomicViews; \
|
||||
make -j 4 KOKKOS_DEVICES=OpenMP
|
||||
|
||||
pthreads:
|
||||
cd ./01_data_layouts; \
|
||||
make -j 4 KOKKOS_DEVICES=Pthreads
|
||||
cd ./02_memory_traits; \
|
||||
make -j 4 KOKKOS_DEVICES=Pthreads
|
||||
cd ./03_subviews; \
|
||||
make -j 4 KOKKOS_DEVICES=Pthreads
|
||||
cd ./04_dualviews; \
|
||||
make -j 4 KOKKOS_DEVICES=Pthreads
|
||||
cd ./05_NVIDIA_UVM; \
|
||||
make -j 4 KOKKOS_DEVICES=Pthreads
|
||||
cd ./06_AtomicViews; \
|
||||
make -j 4 KOKKOS_DEVICES=Pthreads
|
||||
|
||||
serial:
|
||||
cd ./01_data_layouts; \
|
||||
make -j 4 KOKKOS_DEVICES=Serial
|
||||
cd ./02_memory_traits; \
|
||||
make -j 4 KOKKOS_DEVICES=Serial
|
||||
cd ./03_subviews; \
|
||||
make -j 4 KOKKOS_DEVICES=Serial
|
||||
cd ./04_dualviews; \
|
||||
make -j 4 KOKKOS_DEVICES=Serial
|
||||
cd ./05_NVIDIA_UVM; \
|
||||
make -j 4 KOKKOS_DEVICES=Serial
|
||||
cd ./06_AtomicViews; \
|
||||
make -j 4 KOKKOS_DEVICES=Serial
|
||||
|
||||
cuda:
|
||||
cd ./01_data_layouts; \
|
||||
make -j 4 KOKKOS_DEVICES=Cuda,Serial
|
||||
cd ./02_memory_traits; \
|
||||
make -j 4 KOKKOS_DEVICES=Cuda,Serial
|
||||
cd ./03_subviews; \
|
||||
make -j 4 KOKKOS_DEVICES=Cuda,Serial
|
||||
cd ./04_dualviews; \
|
||||
make -j 4 KOKKOS_DEVICES=Cuda,Serial
|
||||
cd ./05_NVIDIA_UVM; \
|
||||
make -j 4 KOKKOS_DEVICES=Cuda,Serial
|
||||
cd ./06_AtomicViews; \
|
||||
make -j 4 KOKKOS_DEVICES=Cuda,Serial
|
||||
|
||||
clean:
|
||||
cd ./01_data_layouts; \
|
||||
make clean
|
||||
cd ./02_memory_traits; \
|
||||
make clean
|
||||
cd ./03_subviews; \
|
||||
make clean
|
||||
cd ./04_dualviews; \
|
||||
make clean
|
||||
cd ./05_NVIDIA_UVM; \
|
||||
make clean
|
||||
cd ./06_AtomicViews; \
|
||||
make clean
|
||||
|
||||
Reference in New Issue
Block a user