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

feature/gemv rps test -- RAJAPerf Suite Version of the BLAS2 GEMV Test #1085

Merged
merged 70 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
9d23ea2
Testing commit
DavidPoliakoff Apr 26, 2021
29d2961
Testing commit
DavidPoliakoff Apr 28, 2021
309cd93
Testing commit
DavidPoliakoff Apr 28, 2021
bc142c9
Mondo commit of RAJAPERF everything. To be trimmed down
DavidPoliakoff May 11, 2021
f553052
Initial, harebrained commit
DavidPoliakoff May 11, 2021
2d427f7
More build fixes
DavidPoliakoff May 11, 2021
64f288d
Commit for demo
DavidPoliakoff May 13, 2021
509a277
Got rid of bad test
DavidPoliakoff May 13, 2021
a7beb1f
BuiltinTimer.hpp: add includes to RPS header
ajpowelsnl May 20, 2021
afdaf6f
perf test data: setter, getter, runtime opts
ajpowelsnl May 21, 2021
4611f0d
KokkosKernelsTrackedTesting.cpp: runtime option
ajpowelsnl May 21, 2021
fe5ceb7
KokkosKernelsTrackedTesting.cpp: help message for input data
May 24, 2021
d102d59
KokkosSparse_spmv_: include QuickKernelBase.hpp
ajpowelsnl Jun 8, 2021
1af92b3
Merge branch 'feature/perf_testing_perfsuite' of github.com:davidpoli…
ajpowelsnl Jun 8, 2021
d4c726c
KokkosBlas_dot_perf_test: KK perf test for RPS implementation
ajpowelsnl Jun 9, 2021
b9e2331
KokkosBlas2_gemv_perf_test:adding pthreads for BMK
ajpowelsnl Jun 10, 2021
0c53bbb
Blas2_gemv_perf_test:adding pthreads handling
ajpowelsnl Jun 10, 2021
8c3e8ee
Merge branch 'blas/dot_test' into feature/perf_testing_perfsuite
ajpowelsnl Jun 15, 2021
f8646f8
KokkosBlas_dot_perf_test_rps: RPS dot implement.
ajpowelsnl Jun 16, 2021
6999e5f
KokkosBlas_dot_perf_test:implement dot w/ TeamPolicy
ajpowelsnl Jun 16, 2021
bda505a
watchr_KokkosConfig.json: reporting for Jenkins job
ajpowelsnl Jun 16, 2021
992f7b4
watchr_KokkosConfig.json: mv to scripts
ajpowelsnl Jun 16, 2021
e108091
watchr_KokkosConfig.json: updating RAJAPerf-timing fname
ajpowelsnl Jun 16, 2021
ed6066e
watchr_KokkosConfig.json: fix up for KK
ajpowelsnl Jun 16, 2021
73e8f9f
watchr_KokkosConfig.json: fix ignore_old_files
ajpowelsnl Jun 16, 2021
4ccc8a4
watchr_KokkosConfig.json: fix KK test name parsing
ajpowelsnl Jun 16, 2021
0efed22
watchr_KokkosConfig.json: fix up regex for KK jobs
ajpowelsnl Jun 16, 2021
4352774
Merge pull request #1 from ajpowelsnl/blas/TeamPolicy_dot_test
ajpowelsnl Jul 1, 2021
1004515
rps as infrastructure
ajpowelsnl Jul 6, 2021
9cf99e7
added git submodule
ajpowelsnl Jul 6, 2021
732a85d
rajaperf as a git submodule
ajpowelsnl Jul 6, 2021
edd1864
tpls/rajaperf: updating watchr json
ajpowelsnl Jul 27, 2021
855927a
dot tests: BUILD FAILURES
ajpowelsnl Jul 27, 2021
be5dedd
tpls/rajaperf: fix watchr config
ajpowelsnl Jul 27, 2021
c84c844
tpls/rajaperf: updating watchr config
ajpowelsnl Jul 28, 2021
6514f1e
tpls/rajaperf: fix up watchr config file
ajpowelsnl Jul 29, 2021
e1da00c
reproducer: undefined reference to `std::__cxx11
ajpowelsnl Jul 29, 2021
c308d6c
tpls/rajaperf: fix up watchr config
ajpowelsnl Jul 30, 2021
f27118e
perf_test: resolve rps v. KK; dot tests
ajpowelsnl Aug 3, 2021
d987a56
Merge remote-tracking branch 'amy_repo/git_submodules_rps_PR' into me…
ajpowelsnl Aug 4, 2021
7c47cd9
Merge remote-tracking branch 'amy_repo/git_submodules_rps_PR' into me…
ajpowelsnl Aug 4, 2021
6d72a44
Merge branch 'merge_dots' of github.com:ajpowelsnl/kokkos-kernels int…
ajpowelsnl Aug 4, 2021
94a7caf
Merge branch 'develop' into git_submodules_rps_PR
ajpowelsnl Aug 5, 2021
3deaa4b
Merge branch 'feature/team_dot_rps' into git_submodules_rps_PR
ajpowelsnl Aug 9, 2021
9b61f83
KokkosSparse_spmv: fix builds
ajpowelsnl Aug 9, 2021
6ca1f1f
cm_generate_makefile.bash:add perfsuite tests flag
ajpowelsnl Aug 9, 2021
8497983
KokkosSparse_spmv_test.cpp: spmv_additional_data fix
ajpowelsnl Aug 9, 2021
105fb60
spmv: fix OpenMP fix ups
ajpowelsnl Aug 11, 2021
5ca7b0c
KokkosBlas2_gemv_perf_test_rps: first draft
ajpowelsnl Aug 11, 2021
1944d9d
bmk: PR comments addressed; linking issues remain
ajpowelsnl Aug 17, 2021
94d9231
fix link errors in spmv: add OpenMPSmartStatic_SPMV.cpp
ajpowelsnl Aug 17, 2021
c23543d
rps build: changes to fix build for PR
ajpowelsnl Aug 17, 2021
c30969d
Merge branch 'git_submodules_rps_PR' into feature/gemv_rps_test
ajpowelsnl Aug 18, 2021
ea683ed
addressing Siva's comments: PR #1085
ajpowelsnl Aug 23, 2021
26bee15
perf_test/CMakeLists.txt: fix formatting
ajpowelsnl Aug 23, 2021
40a7855
perf_test/CMakeLists.txt: fix formatting issues
ajpowelsnl Aug 23, 2021
c0fd6af
PR #1085: address initial BMK comments
ajpowelsnl Aug 25, 2021
bccdb41
PR 1085: bmk comments
ajpowelsnl Aug 26, 2021
f076426
BMK PR coments: addressed on Sept. 1, 2021
ajpowelsnl Sep 1, 2021
3d5c518
git_submodules: fix to get_directories()
ajpowelsnl Sep 13, 2021
3a6c1fc
compiler warn: fixes to stuff AJP, DZP touched
ajpowelsnl Sep 15, 2021
a6347d6
tpls/rajaperf: fix compiler warns
ajpowelsnl Sep 16, 2021
4b648e9
Merge branch 'git_submodules_rps_PR' into feature/gemv_rps_test
ajpowelsnl Sep 16, 2021
d4e1d53
bmk comments: all accepted and addressed
ajpowelsnl Sep 16, 2021
e7e2541
pr_1085: compiler warning fixes
ajpowelsnl Sep 23, 2021
9e2b168
KokkosBlas_team_dot_perf_test: fix functor templating
ajpowelsnl Sep 28, 2021
d62332e
KokkosBlas3_gemm_perf_test.hpp: include Kokkos_Math..
ajpowelsnl Sep 28, 2021
06f0ddb
KokkosBlas_team_dot_perf_test: refactor w/ functor
ajpowelsnl Sep 28, 2021
4bb27c5
Merge branch 'develop' into feature/gemv_rps_test
brian-kelley Oct 1, 2021
bf48607
Remove extra cmake endif
brian-kelley Oct 4, 2021
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 "tpls/rajaperf"]
path = tpls/rajaperf
url = https://github.com/ajpowelsnl/RAJAPerf.git
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ IF (NOT KOKKOSKERNELS_HAS_TRILINOS)
BOOL
"Whether to build tests. Default: OFF"
)
KOKKOSKERNELS_ADD_OPTION(
"ENABLE_TESTS_AND_PERFSUITE"
OFF
BOOL
"Whether to build tests including Perfsuite. Default: OFF"
)
IF(KokkosKernels_ENABLE_TESTS_AND_PERFSUITE)
set(BLT_CODE_CHECK_TARGET_NAME "fix-for-blt" CACHE STRING "Docstring")
set(INFRASTRUCTURE_ONLY ON CACHE BOOL "Only build the RAJAPerf infrastructure, no builtin kernels")
add_definitions("-DRAJAPERF_INFRASTRUCTURE_ONLY")
add_subdirectory(tpls/rajaperf)
include_directories(tpls/rajaperf/src)
ENDIF()
ENDIF ()

KOKKOSKERNELS_ADD_OPTION(
Expand Down
18 changes: 16 additions & 2 deletions cm_generate_makefile.bash
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ get_kernels_extra_linker_flags() {
KOKKOSKERNELS_EXTRA_LINKER_FLAGS_CMD="-DCMAKE_EXE_LINKER_FLAGS=${PARSE_EXTRA_LINKER_FLAGS_LIST} ${KOKKOSKERNELS_EXTRA_LINKER_FLAGS_CMD}"
}



display_help_text() {

echo "KokkosKernels and Kokkos configure options:"
Expand Down Expand Up @@ -331,6 +333,10 @@ display_help_text() {
echo "--gcc-toolchain=/Path/To/GccRoot: Set the gcc toolchain to use with clang (e.g. /usr)"
echo "--kokkos-make-j=[NUM]: Set -j parallel level for kokkos install"
echo " Default: j == 4"
echo "--enable-tests: build Kokkos Kernels unit and performance tests"
echo "--enable-perfsuite: build Kokkos Kernels performance tests with
RAJAPerf Suite"


}

Expand All @@ -339,6 +345,7 @@ KOKKOS_INSTALL_PATH=""
KOKKOS_DO_TESTS=OFF
KOKKOS_DO_EXAMPLES=OFF
KOKKOSKERNELS_DO_TESTS=ON
KOKKOSKERNELS_DO_PERFSUITE=OFF
KOKKOSKERNELS_DO_EXAMPLES=ON

KOKKOS_MAKEINSTALL_J=4
Expand Down Expand Up @@ -491,6 +498,13 @@ do
# This is the default
KOKKOSKERNELS_DO_TESTS=ON
;;
--enable-perfsuite)
KOKKOSKERNELS_DO_PERFSUITE=ON
;;
--disable-perfsuite)
# This is the default
KOKKOSKERNELS_DO_PERFSUITE=OFF
;;
--disable-tests)
KOKKOSKERNELS_DO_TESTS=OFF
;;
Expand Down Expand Up @@ -744,7 +758,7 @@ cd $STORE_KOKKOSKERNELS_BUILD_PATH

# Configure kokkos-kernels
echo ""
echo cmake $COMPILER_CMD -DKokkos_DIR="${KOKKOS_FIND_PATH}" -DCMAKE_CXX_FLAGS="${KOKKOS_CXXFLAGS}" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DKokkosKernels_ENABLE_TESTS=${KOKKOSKERNELS_DO_TESTS} -DKokkosKernels_ENABLE_EXAMPLES:BOOL=${KOKKOSKERNELS_DO_EXAMPLES} ${KOKKOSKERNELS_SCALARS_CMD} ${KOKKOSKERNELS_ORDINALS_CMD} ${KOKKOSKERNELS_OFFSETS_CMD} ${KOKKOSKERNELS_LAYOUTS_CMD} ${KOKKOSKERNELS_TPLS_CMD} ${KOKKOSKERNELS_USER_TPL_PATH_CMD} ${KOKKOSKERNELS_USER_TPL_LIBNAME_CMD} ${KOKKOSKERNELS_EXTRA_LINKER_FLAGS_CMD} ${KOKKOSKERNELS_BUILDTYPE_CMD} ${KOKKOSKERNELS_SPACES_CMD} ${KERNELS_DEFAULT_ETI_OPTION} ${KOKKOSKERNELS_PATH}
echo cmake $COMPILER_CMD -DKokkos_DIR="${KOKKOS_FIND_PATH}" -DCMAKE_CXX_FLAGS="${KOKKOS_CXXFLAGS}" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DKokkosKernels_ENABLE_TESTS_AND_PERFSUITE=${KOKKOSKERNELS_DO_PERFSUITE} -DKokkosKernels_ENABLE_TESTS=${KOKKOSKERNELS_DO_TESTS} -DKokkosKernels_ENABLE_EXAMPLES:BOOL=${KOKKOSKERNELS_DO_EXAMPLES} ${KOKKOSKERNELS_SCALARS_CMD} ${KOKKOSKERNELS_ORDINALS_CMD} ${KOKKOSKERNELS_OFFSETS_CMD} ${KOKKOSKERNELS_LAYOUTS_CMD} ${KOKKOSKERNELS_TPLS_CMD} ${KOKKOSKERNELS_USER_TPL_PATH_CMD} ${KOKKOSKERNELS_USER_TPL_LIBNAME_CMD} ${KOKKOSKERNELS_EXTRA_LINKER_FLAGS_CMD} ${KOKKOSKERNELS_BUILDTYPE_CMD} ${KOKKOSKERNELS_SPACES_CMD} ${KERNELS_DEFAULT_ETI_OPTION} ${KOKKOSKERNELS_PATH}
echo ""
cmake $COMPILER_CMD -DKokkos_DIR="${KOKKOS_FIND_PATH}" -DCMAKE_CXX_FLAGS="${KOKKOS_CXXFLAGS//\"}" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DKokkosKernels_ENABLE_TESTS=${KOKKOSKERNELS_DO_TESTS} -DKokkosKernels_ENABLE_EXAMPLES:BOOL=${KOKKOSKERNELS_DO_EXAMPLES} ${KOKKOSKERNELS_SCALARS_CMD} ${KOKKOSKERNELS_ORDINALS_CMD} ${KOKKOSKERNELS_OFFSETS_CMD} ${KOKKOSKERNELS_LAYOUTS_CMD} ${KOKKOSKERNELS_TPLS_CMD} ${KOKKOSKERNELS_USER_TPL_PATH_CMD} ${KOKKOSKERNELS_USER_TPL_LIBNAME_CMD} ${KOKKOSKERNELS_EXTRA_LINKER_FLAGS_CMD} ${KOKKOSKERNELS_BUILDTYPE_CMD} ${KOKKOSKERNELS_SPACES_CMD} ${KERNELS_DEFAULT_ETI_OPTION} ${KOKKOSKERNELS_PATH}
cmake $COMPILER_CMD -DKokkos_DIR="${KOKKOS_FIND_PATH}" -DCMAKE_CXX_FLAGS="${KOKKOS_CXXFLAGS//\"}" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DKokkosKernels_ENABLE_TESTS_AND_PERFSUITE=${KOKKOSKERNELS_DO_PERFSUITE} -DKokkosKernels_ENABLE_TESTS=${KOKKOSKERNELS_DO_TESTS} -DKokkosKernels_ENABLE_EXAMPLES:BOOL=${KOKKOSKERNELS_DO_EXAMPLES} ${KOKKOSKERNELS_SCALARS_CMD} ${KOKKOSKERNELS_ORDINALS_CMD} ${KOKKOSKERNELS_OFFSETS_CMD} ${KOKKOSKERNELS_LAYOUTS_CMD} ${KOKKOSKERNELS_TPLS_CMD} ${KOKKOSKERNELS_USER_TPL_PATH_CMD} ${KOKKOSKERNELS_USER_TPL_LIBNAME_CMD} ${KOKKOSKERNELS_EXTRA_LINKER_FLAGS_CMD} ${KOKKOSKERNELS_BUILDTYPE_CMD} ${KOKKOSKERNELS_SPACES_CMD} ${KERNELS_DEFAULT_ETI_OPTION} ${KOKKOSKERNELS_PATH}

3 changes: 3 additions & 0 deletions cmake/KokkosKernels_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
than just BLAS and LAPACK functions. */
#cmakedefine HAVE_KOKKOSKERNELS_MKL


#cmakedefine KOKKOSKERNELS_ENABLE_TESTS_AND_PERFSUITE

/* Define this macro if experimental features of Kokkoskernels are enabled */
#cmakedefine HAVE_KOKKOSKERNELS_EXPERIMENTAL

Expand Down
5 changes: 5 additions & 0 deletions cmake/kokkoskernels_tribits.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ IF (IS_ENABLED)
TESTONLYLIBS ${PARSE_TESTONLYLIBS})
ELSE()
ADD_EXECUTABLE(${EXE_NAME} ${PARSE_SOURCES})
#AJP, BMK altered:
IF(KOKKOSKERNELS_ENABLE_TESTS_AND_PERFSUITE)
TARGET_LINK_LIBRARIES(${EXE_NAME} PRIVATE common ${PARSE_TESTONLYLIBS})
ENDIF()

IF (PARSE_TESTONLYLIBS)
TARGET_LINK_LIBRARIES(${EXE_NAME} PRIVATE Kokkos::kokkoskernels ${PARSE_TESTONLYLIBS})
ELSE ()
Expand Down
44 changes: 29 additions & 15 deletions perf_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,43 @@ KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../test_common)

# At some point, we may wish to make this into real "performance
# tests," in the sense that they can pass or fail. At that point, use
# "CATEGORIES PERFORMANCE" to mark them as such. For now, we just
# build the executables for manual use, but don't run the tests. They
# build correctly with or without MPI, but only run them with a single
# MPI process.
#At some point, we may wish to make this into real "performance
#tests, " in the sense that they can pass or fail. At that point, use
#"CATEGORIES PERFORMANCE" to mark them as such.For now, we just
#build the executables for manual use, but don't run the tests. They
#build correctly with or without MPI, but only run them with a single
#MPI process.

SET(GTEST_SOURCE_DIR ${PACKAGE_SOURCE_DIR}/tpls/gtest)

KOKKOSKERNELS_ADD_TEST_LIBRARY(
kokkoskernelsperf_gtest
HEADERS ${GTEST_SOURCE_DIR}/gtest/gtest.h
SOURCES ${GTEST_SOURCE_DIR}/gtest/gtest-all.cc
)
# Disables pthreads, this is a problem for serial builds in Trilinos & Sierra if it's enabled.
kokkoskernelsperf_gtest
HEADERS ${GTEST_SOURCE_DIR}/gtest/gtest.h
SOURCES ${GTEST_SOURCE_DIR}/gtest/gtest-all.cc
)
#Disables pthreads, this is a problem for serial builds in Trilinos & Sierra if it's enabled.

TARGET_COMPILE_DEFINITIONS(kokkoskernelsperf_gtest PUBLIC "-DGTEST_HAS_PTHREAD=0")
TARGET_INCLUDE_DIRECTORIES(kokkoskernelsperf_gtest PUBLIC $<BUILD_INTERFACE:${GTEST_SOURCE_DIR}>)

#Gtest minimally requires C++11
#Gtest minimally requires C++ 11
TARGET_COMPILE_FEATURES(kokkoskernelsperf_gtest PUBLIC cxx_std_11)



include_directories(sparse)
if (KokkosKernels_ENABLE_TESTS_AND_PERFSUITE)
#Add RPS implementations of KK perf tests here

KOKKOSKERNELS_ADD_EXECUTABLE(
tracked_testing
SOURCES KokkosKernelsTrackedTesting.cpp
sparse/KokkosSparse_spmv_test.cpp
blas/blas2/KokkosBlas2_gemv_tracked_perf_test.cpp
blas/blas1/KokkosBlas_dot_tracked_perf_test.cpp
blas/blas1/KokkosBlas_team_dot_tracked_perf_test.cpp
PerfTestUtilities.cpp
sparse/spmv/OpenMPSmartStatic_SPMV.cpp
#sparse / KokkosSparse_spgemm_test.cpp
)
endif()
ADD_COMPONENT_SUBDIRECTORY(batched)
ADD_COMPONENT_SUBDIRECTORY(graph)
ADD_COMPONENT_SUBDIRECTORY(sparse)
Expand Down
72 changes: 72 additions & 0 deletions perf_test/KokkosKernelsTrackedTesting.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// Created by Poliakoff, David Zoeller on 4/26/21.
//
#include <common/RAJAPerfSuite.hpp>
#include <common/Executor.hpp>
#include "sparse/tracked_testing.hpp"
#include <iostream>
#include <Kokkos_Core.hpp>
// For RPS version of BLAS Level-1 Tests
#include "blas/blas1/tracked_testing.hpp"
#include "blas/blas2/tracked_testing.hpp"
int main(int argc, char* argv[]) {
{
// argument parsing for setting input data at runtime

std::string inputDataPath;
if (argc == 1) {
// print_help();
std::cout << "Please provide input data directory: --input-data "
"/PATH/TO/KOKKOS-KERNELS/INPUT/DATA"
<< std::endl;
return 0;
}

for (int i = 0; i < argc; i++) {
// if((strcmp(argv[i],"-v")==0)) {numVecs=atoi(argv[++i]); continue;}
if ((strcmp(argv[i], "--input-data") == 0)) {
i++;

if (i == argc) {
std::cerr << "Must pass desired input data after '--input-data'";
exit(1);
}
inputDataPath = std::string(argv[i]);
continue;
}
}

test::set_input_data_path(inputDataPath);

// set up Executor
rajaperf::Executor exec(0, argv);
// rajaperf::Executor exec(argc, argv);
rajaperf::RunParams run_params(0, argv);
// Initialize Kokkos
Kokkos::initialize(argc, argv);

Kokkos::print_configuration(std::cout);

// sparse , spmv
test::sparse::build_executor(exec, argc, argv, run_params);

// All BLAS tests (Dot, Team Dot)
test::blas::build_blas_executor(exec, argc, argv, run_params);

test::blas2::build_blas2_executor(exec, argc, argv, run_params);

exec.setupSuite();

// STEP 3: Report suite run summary
// (enable users to catch errors before entire suite is run)
exec.reportRunSummary(std::cout);

// STEP 4: Execute suite
exec.runSuite();

// STEP 5: Generate suite execution reports
exec.outputRunData();
}
Kokkos::finalize();
return 0;
}
15 changes: 15 additions & 0 deletions perf_test/PerfTestUtilities.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Created by Poliakoff, David Zoeller on 4/27/21.
//

#include <string>

namespace test {

std::string inputDataPath;

void set_input_data_path(const std::string& path_to_data) {
inputDataPath = path_to_data;
}
std::string get_input_data_path() { return inputDataPath; }
} // namespace test
118 changes: 118 additions & 0 deletions perf_test/PerfTestUtilities.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
//
// Created by Poliakoff, David Zoeller on 4/27/21.
//

#ifndef KOKKOSKERNELS_PERFTESTUTILITIES_HPP
#define KOKKOSKERNELS_PERFTESTUTILITIES_HPP
#include "KokkosKernels_default_types.hpp"
#include "KokkosKernels_config.h"
#include "KokkosKernels_IOUtils.hpp"
#include <common/RunParams.hpp>
#include <common/QuickKernelBase.hpp>
#include <common/KernelBase.hpp>
#include <dirent.h>

namespace test {
void set_input_data_path(const std::string &path_to_data);

std::string get_input_data_path();

} // namespace test

namespace KokkosSparse {

template <class Scalar, class Ordinal, class ExecutionSpace, class,
class Offset>
class CrsMatrix;
}

// helper function for get_directories
inline bool isDirectory(std::string path) {
DIR *dirp; // Pointer to a directory
dirp = opendir(path.c_str());
// bool var indicating that dirp is not NULL, i.e., a true statement
bool isDir = dirp != NULL;
if (dirp != NULL) closedir(dirp);
return isDir;
}

/** TODO: fix in C++17 */
inline std::vector<std::string> get_directories(std::string path) {
DIR *d;
std::vector<std::string> paths;
struct dirent *dir;
d = opendir(path.c_str());
if (d) {
while ((dir = readdir(d)) != NULL) {
std::string nname = std::string(dir->d_name);
// Check to see if item is a directory
//if (isDirectory(path + '/' + nname))
if(nname != "." && nname != ".." && isDirectory(path + '/' + dir->d_name))
// std::vector::emplace_back: insert a new element to the end of vector
paths.emplace_back(dir->d_name);
}
closedir(d);
}
return paths;
}

namespace readers {

template <class Scalar, class Ordinal, class ExecutionSpace, class Offset>
using matrix_type =
KokkosSparse::CrsMatrix<Scalar, Ordinal, ExecutionSpace, void, Offset>;

template <class>
struct test_reader;

template <class Scalar, class Ordinal, class ExecutionSpace, class Offset>
struct test_reader<matrix_type<Scalar, Ordinal, ExecutionSpace, Offset>> {
static matrix_type<Scalar, Ordinal, ExecutionSpace, Offset> read(
const std::string &filename) {
return KokkosKernels::Impl::read_kokkos_crst_matrix<
matrix_type<Scalar, Ordinal, ExecutionSpace, Offset>>(filename.c_str());
}
};

} // namespace readers
template <class... SubComponents>
struct data_retriever {
std::string root_path;
std::string sub_path;
struct test_case {
std::string filename;
std::tuple<SubComponents...> test_data;
};
std::vector<test_case> test_cases;
std::string make_full_path_to_data_file(std::string repo,
std::string path_to_data,
std::string dataset,
std::string filename) {
return root_path + "/" + repo + "/" + path_to_data + dataset + "/" +
filename;
}
template <class... Locations>
data_retriever(std::string path_to_data, Locations... locations)
: sub_path(path_to_data) {
root_path = test::get_input_data_path();

// TODO: way to list the directories in the root path
std::vector<std::string> data_repos = get_directories(root_path + "/");
// TODO: list directories in subpaths
for (auto repo : data_repos) {
std::vector<std::string> datasets =
get_directories(root_path + "/" + repo + "/" + path_to_data + "/");
for (auto dataset : datasets) {
test_cases.push_back(
test_case{repo + "/" + dataset,
std::make_tuple(readers::test_reader<SubComponents>::read(
make_full_path_to_data_file(
repo, path_to_data, dataset, locations))...)});
}
}
}
};

using test_list = std::vector<rajaperf::KernelBase *>;

#endif // KOKKOSKERNELS_PERFTESTUTILITIES_HPP
Loading