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

Add test for --kokkos-trace #587

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "sample/external/kokkos"]
path = sample/external/kokkos
url = https://github.com/kokkos/kokkos
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ message(STATUS "Pytest CPU threadcount: ${PYTEST_NUMPROCS}")
# ---------------------------
# profile mode tests
# ---------------------------
add_test(
NAME test_profile_kokkos_trace
COMMAND
${Python3_EXECUTABLE} -m pytest -m kokkos
--junitxml=tests/test_profile_kokkos_trace.xml ${COV_OPTION}
${PROJECT_SOURCE_DIR}/tests/test_profile_general.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

add_test(
NAME test_profile_kernel_execution
Expand Down Expand Up @@ -245,6 +252,7 @@ add_test(
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

set_tests_properties(
test_profile_kokkos_trace
test_profile_kernel_execution
test_profile_ipblocks
test_profile_dispatch
Expand Down Expand Up @@ -531,4 +539,4 @@ set(CPACK_SOURCE_IGNORE_FILES
/tests
/build)

include(CPack)
include(CPack)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pythonpath = [
]

markers = [
"kokkos",
"kernel_execution",
"block",
"misc",
Expand Down
1 change: 1 addition & 0 deletions sample/external/kokkos
Submodule kokkos added at 0766bc
44 changes: 44 additions & 0 deletions sample/kokkos-no-uvm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#Set your Kokkos path to something appropriate
KOKKOS_PATH = ${CURDIR}/../external/kokkos
KOKKOS_DEVICES = "HIP"
KOKKOS_ARCH = "AMD_GFX942"
KOKKOS_CUDA_OPTIONS = enable_lambda
SRC = $(wildcard *.cc)

default: build
echo "Start Build"

CXXFLAGS = -g -O3 -DUSE_OMP=1 -lineinfo -DRAJA_USE_GETTIME -I./includes -I./ -lineinfo

ifeq ( $(USE_MPI), yes)
CXX = hipcc
CXXFLAGS += -DUSE_MPI=1
else
CXX = hipcc
CXXFLAGS += -DUSE_MPI=0
endif

LINK = ${CXX}

LINKFLAGS =
EXE = lulesh.kk

DEPFLAGS = -M

OBJ = $(SRC:.cc=.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

# Compilation rules

%.o:%.cc $(KOKKOS_CPP_DEPENDS) lulesh.h lulesh_tuple.h
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<
47 changes: 47 additions & 0 deletions sample/kokkos-no-uvm/Makefile.cuda
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#Set your Kokkos path to something appropriate
KOKKOS_PATH = ${HOME}/Kokkos/kokkos
KOKKOS_DEVICES = "Cuda,OpenMP"
KOKKOS_ARCH = "Volta70"
KOKKOS_CUDA_OPTIONS = enable_lambda
SRC = $(wildcard *.cc)

default: build
echo "Start Build"

CXXFLAGS = -g -O3 -DUSE_OMP=1 -lineinfo -DRAJA_USE_GETTIME -I./includes -I./ -lineinfo

ifeq ( $(USE_MPI), yes)
CXX = mpicxx
CXXFLAGS += -DUSE_MPI=1
else
CXX = ${KOKKOS_PATH}/bin/nvcc_wrapper
CXXFLAGS += -DUSE_MPI=0
endif

LINK = ${CXX}

LINKFLAGS =
EXE = lulesh.cuda

DEPFLAGS = -M

OBJ = $(SRC:.cc=.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

# Compilation rules

%.o:%.cc $(KOKKOS_CPP_DEPENDS) lulesh.h lulesh_tuple.h
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) $(EXTRA_INC) -c $<



113 changes: 113 additions & 0 deletions sample/kokkos-no-uvm/includes/Timer.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*!
******************************************************************************
*
* \file
*
* \brief RAJA header file for simple class that can be used to
* time code sections.
*
* \author Rich Hornung, Center for Applied Scientific Computing, LLNL
* \author Jeff Keasler, Applications, Simulations And Quality, LLNL
*
******************************************************************************
*/

#ifndef RAJA_Timer_HXX
#define RAJA_Timer_HXX


#if defined(RAJA_USE_CYCLE)
#include "./cycle.h"
typedef ticks TimeType;

#elif defined(RAJA_USE_CLOCK)
#include <time.h>
typedef clock_t TimeType;

#elif defined(RAJA_USE_GETTIME)
#include <time.h>
typedef timespec TimeType;

#else
#error RAJA_TIMER_TYPE is undefined!

#endif



namespace RAJA {


/*!
******************************************************************************
*
* \brief Simple timer class to time code sections.
*
******************************************************************************
*/
class Timer
{
public:
#if defined(RAJA_USE_CYCLE) || defined(RAJA_USE_CLOCK)
Timer() : telapsed(0) { ; }
#endif
#if defined(RAJA_USE_GETTIME)
Timer() : telapsed(0), stime_elapsed(0), nstime_elapsed(0) { ; }
#endif

#if defined(RAJA_USE_CYCLE)
void start() { tstart = getticks(); }
void stop() { tstop = getticks(); set_elapsed(); }

long double elapsed()
{ return static_cast<long double>(telapsed); }
#endif

#if defined(RAJA_USE_CLOCK)
void start() { tstart = clock(); }
void stop() { tstop = clock(); set_elapsed(); }

long double elapsed()
{ return static_cast<long double>(telapsed) / CLOCKS_PER_SEC; }
#endif

#if defined(RAJA_USE_GETTIME)

#if 0
void start() { clock_gettime(CLOCK_REALTIME, &tstart); }
void stop() { clock_gettime(CLOCK_REALTIME, &tstop); set_elapsed(); }
#else
void start() { clock_gettime(CLOCK_MONOTONIC, &tstart); }
void stop() { clock_gettime(CLOCK_MONOTONIC, &tstop); set_elapsed(); }
#endif

long double elapsed()
{ return (stime_elapsed + nstime_elapsed); }

#endif

private:
TimeType tstart;
TimeType tstop;
long double telapsed;

#if defined(RAJA_USE_CYCLE) || defined(RAJA_USE_CLOCK)
void set_elapsed() { telapsed += (tstop - tstart); }

#elif defined(RAJA_USE_GETTIME)
long double stime_elapsed;
long double nstime_elapsed;

void set_elapsed() { stime_elapsed += static_cast<long double>(
tstop.tv_sec - tstart.tv_sec);
nstime_elapsed += static_cast<long double>(
tstop.tv_nsec - tstart.tv_nsec ) /
1000000000.0; }
#endif

};


} // closing brace for RAJA namespace

#endif // closing endif for header file include guard
Loading
Loading