Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Make DPC++ tests work with the new system.
  • Loading branch information
Terry Cojean committed Apr 29, 2021
commit 8474390244a637411353fa980e47db24e9d8ed5e
40 changes: 36 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ include:
BUILD_HIP: "OFF"
BUILD_HWLOC: "ON"
FAST_TESTS: "OFF"
DPCPP_SINGLE_MODE: "OFF"
RUN_EXAMPLES: "OFF"
CONFIG_LOG: "ON"
CXX_FLAGS: ""
Expand Down Expand Up @@ -64,7 +65,6 @@ include:
CUDA_HOST_STR=-DCMAKE_CUDA_HOST_COMPILER=$(which ${CXX_COMPILER});
export CUDA_VISIBLE_DEVICES=$((RANDOM % 2));
fi
- if [ ! -z ${SYCL_DEVICE_TYPE+x} ]; then export SYCL_DEVICE_TYPE; fi
- cmake ${CI_PROJECT_DIR}${CI_PROJECT_DIR_SUFFIX}
-GNinja
-DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${CXX_COMPILER}
Expand All @@ -79,9 +79,9 @@ include:
-DGINKGO_FAST_TESTS=${FAST_TESTS}
-DGINKGO_RUN_EXAMPLES=${RUN_EXAMPLES}
-DGINKGO_CONFIG_LOG_DETAILED=${CONFIG_LOG}
-DGINKGO_DPCPP_SINGLE_MODE=${DPCPP_SINGLE_MODE}
-DGINKGO_EXPORT_BUILD_DIR=${EXPORT_BUILD_DIR}
- ninja -j${NUM_CORES} -l${CI_LOAD_LIMIT} install
- if [ ! -z ${SYCL_DEVICE_TYPE+x} ]; then unset SYCL_DEVICE_TYPE; fi
- if [ "${EXPORT_BUILD_DIR}" == "ON" ]; then ninja test_exportbuild; fi
dependencies: []
except:
Expand All @@ -98,7 +98,7 @@ include:
CUDA_HOST_STR=-DCMAKE_CUDA_HOST_COMPILER=$(which ${CXX_COMPILER});
export CUDA_VISIBLE_DEVICES=$((RANDOM % 2));
fi
- if [ ! -z ${SYCL_DEVICE_TYPE+x} ]; then export SYCL_DEVICE_TYPE; fi
- if [ -n "${SYCL_DEVICE_FILTER}" ]; then export SYCL_DEVICE_FILTER; fi
- cmake ${CI_PROJECT_DIR}${CI_PROJECT_DIR_SUFFIX}
-GNinja
-DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${CXX_COMPILER}
Expand All @@ -112,6 +112,7 @@ include:
-DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_EXAMPLES=ON
-DGINKGO_FAST_TESTS=${FAST_TESTS}
-DGINKGO_CONFIG_LOG_DETAILED=${CONFIG_LOG}
-DGINKGO_DPCPP_SINGLE_MODE=${DPCPP_SINGLE_MODE}
-DGINKGO_RUN_EXAMPLES=${RUN_EXAMPLES}
-DGINKGO_EXPORT_BUILD_DIR=${EXPORT_BUILD_DIR}
- ninja -j${NUM_CORES} -l${CI_LOAD_LIMIT} install
Expand Down Expand Up @@ -143,7 +144,7 @@ include:
ninja validate_all_examples
fi
fi
- if [ ! -z ${SYCL_DEVICE_TYPE+x} ]; then unset SYCL_DEVICE_TYPE; fi
- if [ -n "${SYCL_DEVICE_FILTER}" ]; then unset SYCL_DEVICE_FILTER; fi
- if [ "${EXPORT_BUILD_DIR}" == "ON" ]; then ninja test_exportbuild; fi
dependencies: []
except:
Expand Down Expand Up @@ -680,6 +681,37 @@ build/nocuda/intel/omp/release/static:
BUILD_TYPE: "Release"
BUILD_SHARED_LIBS: "OFF"


build/dpcpp/igpu/release/static:
<<: *default_build_with_test
extends:
- .full_test_condition
- .use_gko-oneapi-igpu
variables:
<<: *default_variables
C_COMPILER: "gcc"
CXX_COMPILER: "dpcpp"
BUILD_DPCPP: "ON"
BUILD_TYPE: "Release"
BUILD_SHARED_LIBS: "OFF"
DPCPP_SINGLE_MODE: "ON"
SYCL_DEVICE_FILTER: "GPU"

build/dpcpp/dgpu/debug/shared:
<<: *default_build_with_test
image: localhost:5000/gko-oneapi
extends:
- .quick_test_condition
- .use_gko-oneapi-dgpu
variables:
<<: *default_variables
C_COMPILER: "gcc"
CXX_COMPILER: "dpcpp"
BUILD_DPCPP: "ON"
BUILD_TYPE: "Debug"
DPCPP_SINGLE_MODE: "ON"
SYCL_DEVICE_FILTER: "Level_Zero:GPU"
Comment thread
tcojean marked this conversation as resolved.

# Job with important warnings as error
warnings:
<<: *default_build
Expand Down
16 changes: 14 additions & 2 deletions .gitlab/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,21 @@
- amdci
- gpu

.use_gko-oneapi:
.use_gko-oneapi-cpu:
image: ginkgohub/oneapi:latest
tags:
- private_ci
- bwuni
- intelci-igpu
- cpu

.use_gko-oneapi-igpu:
image: localhost:5000/gko-oneapi
tags:
- private_ci
- intel-igpu
Comment thread
yhmtsai marked this conversation as resolved.

.use_gko-oneapi-dgpu:
image: localhost:5000/gko-oneapi
tags:
- private_ci
- intel-dgpu
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.13)

# Use *_ROOT environment variables for find_package calls
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
cmake_policy(SET CMP0074 NEW)
endif()
cmake_policy(SET CMP0074 NEW)

# Let CAS handle the CUDA architecture flags (for now)
# Windows still gives CMP0104 warning if putting it in cuda.
Expand Down Expand Up @@ -54,6 +52,11 @@ set(GINKGO_VERBOSE_LEVEL "1" CACHE STRING
if(MSVC)
set(GINKGO_COMPILER_FLAGS "" CACHE STRING
"Set the required CXX compiler flags, mainly used for warnings. Current default is ``")
elseif(GINKGO_BUILD_DPCPP OR CMAKE_CXX_COMPILER MATCHES "dpcpp")
# For now always use `-ffp-model=precise` with DPC++. This can be removed when
# the floating point issues are fixed.
set(GINKGO_COMPILER_FLAGS "-Wpedantic;-ffp-model=precise" CACHE STRING
"Set the required CXX compiler flags, mainly used for warnings. Current default is `-Wpedantic;-fp-model strict`")
Comment thread
tcojean marked this conversation as resolved.
Outdated
else()
set(GINKGO_COMPILER_FLAGS "-Wpedantic" CACHE STRING
"Set the required CXX compiler flags, mainly used for warnings. Current default is `-Wpedantic`")
Expand All @@ -78,6 +81,7 @@ if(MSVC OR WIN32 OR CYGWIN OR APPLE)
else()
option(GINKGO_BUILD_HWLOC "Build Ginkgo with HWLOC. Default is ON. If a system HWLOC is not found, then we try to build it ourselves. Switch this OFF to disable HWLOC." ON)
endif()
option(GINKGO_DPCPP_SINGLE_MODE "Do not compile double kernels for the DPC++ backend." OFF)
Comment thread
tcojean marked this conversation as resolved.
option(GINKGO_INSTALL_RPATH "Set the RPATH when installing its libraries." ON)
option(GINKGO_INSTALL_RPATH_ORIGIN "Add $ORIGIN (Linux) or @loader_path (MacOS) to the installation RPATH." ON)
option(GINKGO_INSTALL_RPATH_DEPENDENCIES "Add dependencies to the installation RPATH." OFF)
Expand Down
1 change: 1 addition & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function(ginkgo_add_single_benchmark_executable name use_lib_linops macro_def)
add_executable("${name}" ${ARGN})
target_link_libraries("${name}" ginkgo gflags rapidjson)
target_compile_definitions("${name}" PRIVATE "${macro_def}")
target_compile_options("${name}" PRIVATE ${GINKGO_COMPILER_FLAGS})
ginkgo_benchmark_add_tuning_maybe("${name}")
if("${use_lib_linops}")
if (GINKGO_BUILD_CUDA)
Expand Down
9 changes: 9 additions & 0 deletions cmake/create_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function(ginkgo_create_test test_name)
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
target_compile_features("${TEST_TARGET_NAME}" PUBLIC cxx_std_14)
target_compile_options("${TEST_TARGET_NAME}" PRIVATE ${GINKGO_COMPILER_FLAGS})
target_include_directories("${TEST_TARGET_NAME}"
PRIVATE
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
Expand All @@ -13,6 +14,9 @@ function(ginkgo_create_test test_name)
if (GINKGO_FAST_TESTS)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE GINKGO_FAST_TESTS)
endif()
if (GINKGO_COMPILING_DPCPP_TEST AND GINKGO_DPCPP_SINGLE_MODE)
target_compile_definitions("${TEST_TARGET_NAME}" PRIVATE GINKGO_DPCPP_SINGLE_MODE=1)
endif()
if (GINKGO_CHECK_CIRCULAR_DEPS)
target_link_libraries(${TEST_TARGET_NAME} PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}")
endif()
Expand All @@ -27,6 +31,9 @@ function(ginkgo_create_dpcpp_test test_name)
add_executable(${TEST_TARGET_NAME} ${test_name}.dp.cpp)
target_compile_features("${TEST_TARGET_NAME}" PUBLIC cxx_std_17)
target_compile_options("${TEST_TARGET_NAME}" PRIVATE "${GINKGO_DPCPP_FLAGS}")
if (GINKGO_DPCPP_SINGLE_MODE)
target_compile_definitions("${TEST_TARGET_NAME}" PRIVATE GINKGO_DPCPP_SINGLE_MODE=1)
endif()
target_include_directories("${TEST_TARGET_NAME}"
PRIVATE
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
Expand All @@ -51,6 +58,7 @@ function(ginkgo_create_thread_test test_name)
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
target_compile_features("${TEST_TARGET_NAME}" PUBLIC cxx_std_14)
target_compile_options("${TEST_TARGET_NAME}" PRIVATE ${GINKGO_COMPILER_FLAGS})
target_include_directories("${TEST_TARGET_NAME}"
PRIVATE
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
Expand All @@ -74,6 +82,7 @@ function(ginkgo_create_test_cpp_cuda_header test_name)
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
target_compile_features("${TEST_TARGET_NAME}" PUBLIC cxx_std_14)
target_compile_options("${TEST_TARGET_NAME}" PRIVATE ${GINKGO_COMPILER_FLAGS})
target_include_directories("${TEST_TARGET_NAME}"
PRIVATE
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
Expand Down
8 changes: 4 additions & 4 deletions core/test/log/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <gtest/gtest.h>


#include <ginkgo/core/log/record.hpp>
#include <ginkgo/core/log/convergence.hpp>
#include <ginkgo/core/log/stream.hpp>


Expand All @@ -66,7 +66,7 @@ TEST(DummyLogged, CanAddLogger)
DummyLoggedClass c;

c.add_logger(
gko::log::Record::create(exec, gko::log::Logger::all_events_mask));
gko::log::Convergence<>::create(exec, gko::log::Logger::all_events_mask));

ASSERT_EQ(c.get_num_loggers(), 1);
}
Expand All @@ -78,7 +78,7 @@ TEST(DummyLogged, CanAddMultipleLoggers)
DummyLoggedClass c;

c.add_logger(
gko::log::Record::create(exec, gko::log::Logger::all_events_mask));
gko::log::Convergence<>::create(exec, gko::log::Logger::all_events_mask));
c.add_logger(gko::log::Stream<>::create(
exec, gko::log::Logger::all_events_mask, std::cout));

Expand Down Expand Up @@ -125,7 +125,7 @@ TEST(DummyLogged, CanRemoveLogger)
auto exec = gko::ReferenceExecutor::create();
DummyLoggedClass c;
auto r = gko::share(
gko::log::Record::create(exec, gko::log::Logger::all_events_mask));
gko::log::Convergence<>::create(exec, gko::log::Logger::all_events_mask));
c.add_logger(r);
c.add_logger(gko::log::Stream<>::create(
exec, gko::log::Logger::all_events_mask, std::cout));
Expand Down
2 changes: 1 addition & 1 deletion core/test/multigrid/amgx_pgm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AmgxPgmFactory : public ::testing::Test {
std::unique_ptr<typename MgLevel::Factory> amgxpgm_factory;
};

TYPED_TEST_CASE(AmgxPgmFactory, gko::test::ValueIndexTypes);
TYPED_TEST_SUITE(AmgxPgmFactory, gko::test::ValueIndexTypes);


TYPED_TEST(AmgxPgmFactory, FactoryKnowsItsExecutor)
Expand Down
2 changes: 1 addition & 1 deletion core/test/solver/cb_gmres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ using TestTypes =
std::tuple<std::complex<double>, st_r2>,
std::tuple<std::complex<float>, st_keep>>;

TYPED_TEST_CASE(CbGmres, TestTypes);
TYPED_TEST_SUITE(CbGmres, TestTypes);


TYPED_TEST(CbGmres, CbGmresFactoryKnowsItsExecutor)
Expand Down
2 changes: 1 addition & 1 deletion core/test/solver/idr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Idr : public ::testing::Test {
}
};

TYPED_TEST_CASE(Idr, gko::test::ValueTypes);
TYPED_TEST_SUITE(Idr, gko::test::ValueTypes);


TYPED_TEST(Idr, IdrFactoryKnowsItsExecutor)
Expand Down
63 changes: 51 additions & 12 deletions core/test/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,41 +57,80 @@ namespace test {


using ValueTypes =
#if GINKGO_DPCPP_SINGLE_MODE
::testing::Types<float, std::complex<float>>;
#else
::testing::Types<float, double, std::complex<float>, std::complex<double>>;
#endif


using ComplexValueTypes =
#if GINKGO_DPCPP_SINGLE_MODE
::testing::Types<std::complex<float>>;
#else
::testing::Types<std::complex<float>, std::complex<double>>;
#endif


using IndexTypes = ::testing::Types<gko::int32, gko::int64>;


using ValueAndIndexTypes =
#if GINKGO_DPCPP_SINGLE_MODE
::testing::Types<float, std::complex<float>, gko::int32, gko::int64,
gko::size_type>;
#else
::testing::Types<float, double, std::complex<float>, std::complex<double>,
gko::int32, gko::int64, gko::size_type>;
#endif


using RealValueAndIndexTypes =
#if GINKGO_DPCPP_SINGLE_MODE
::testing::Types<float, gko::int32, gko::int64, gko::size_type>;
#else
::testing::Types<float, double, gko::int32, gko::int64, gko::size_type>;

using ValueIndexTypes = ::testing::Types<
std::tuple<float, gko::int32>, std::tuple<double, gko::int32>,
std::tuple<std::complex<float>, gko::int32>,
std::tuple<std::complex<double>, gko::int32>, std::tuple<float, gko::int64>,
std::tuple<double, gko::int64>, std::tuple<std::complex<float>, gko::int64>,
std::tuple<std::complex<double>, gko::int64>>;


using RealValueIndexTypes = ::testing::Types<
std::tuple<float, gko::int32>, std::tuple<double, gko::int32>,
std::tuple<float, gko::int64>, std::tuple<double, gko::int64>>;
#endif


using ValueIndexTypes =
#if GINKGO_DPCPP_SINGLE_MODE
::testing::Types<std::tuple<float, gko::int32>,
std::tuple<std::complex<float>, gko::int32>,
std::tuple<float, gko::int64>,
std::tuple<std::complex<float>, gko::int64>>;
#else
::testing::Types<
std::tuple<float, gko::int32>, std::tuple<double, gko::int32>,
std::tuple<std::complex<float>, gko::int32>,
std::tuple<std::complex<double>, gko::int32>,
std::tuple<float, gko::int64>, std::tuple<double, gko::int64>,
std::tuple<std::complex<float>, gko::int64>,
std::tuple<std::complex<double>, gko::int64>>;
#endif


using RealValueIndexTypes =
#if GINKGO_DPCPP_SINGLE_MODE
::testing::Types<std::tuple<float, gko::int32>,
std::tuple<float, gko::int64>>;
#else
::testing::Types<
std::tuple<float, gko::int32>, std::tuple<double, gko::int32>,
std::tuple<float, gko::int64>, std::tuple<double, gko::int64>>;
#endif


using ComplexValueIndexTypes =
#if GINKGO_DPCPP_SINGLE_MODE
::testing::Types<std::tuple<std::complex<float>, gko::int32>,
std::tuple<std::complex<float>, gko::int64>>;
#else
::testing::Types<std::tuple<std::complex<float>, gko::int32>,
std::tuple<std::complex<double>, gko::int32>,
std::tuple<std::complex<float>, gko::int64>,
std::tuple<std::complex<double>, gko::int64>>;
#endif


template <typename Precision, typename OutputType>
Expand Down
6 changes: 5 additions & 1 deletion dpcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ target_sources(ginkgo_dpcpp

ginkgo_compile_features(ginkgo_dpcpp)

set(GINKGO_DPCPP_FLAGS ${GINKGO_COMPILER_FLAGS} -fsycl -fsycl-device-lib=libc)
set(GINKGO_DPCPP_FLAGS ${GINKGO_COMPILER_FLAGS} -fsycl)
set(GINKGO_DPCPP_FLAGS ${GINKGO_DPCPP_FLAGS} PARENT_SCOPE)
target_compile_options(ginkgo_dpcpp PRIVATE "${GINKGO_DPCPP_FLAGS}")
target_compile_features(ginkgo_dpcpp PRIVATE cxx_std_17)
target_link_options(ginkgo_dpcpp PRIVATE -fsycl-device-lib=all)
Comment thread
tcojean marked this conversation as resolved.
target_link_libraries(ginkgo_dpcpp PUBLIC ginkgo_device)
if (GINKGO_DPCPP_SINGLE_MODE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because -fsycl-device-code-split=per_kernel, should we separate the SINGLE_MODE to build/test usage?
To test full build on float-only device

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I do not understand this one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we add the link flag into ginkgo library, which allows us to use single kernel (test) on single-only device even if compiling ginkgo with double kernel

target_compile_definitions(ginkgo_dpcpp PRIVATE GINKGO_DPCPP_SINGLE_MODE=1)
endif()

ginkgo_default_includes(ginkgo_dpcpp)
ginkgo_install_library(ginkgo_dpcpp)
Expand Down
4 changes: 2 additions & 2 deletions dpcpp/components/absolute_array.dp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void inplace_absolute_array(std::shared_ptr<const DefaultExecutor> exec,
exec->get_queue()->submit([&](sycl::handler &cgh) {
cgh.parallel_for(sycl::range<1>{n}, [=](sycl::id<1> idx_id) {
const auto idx = idx_id[0];
data[idx] = dpcpp::abs(data[idx]);
data[idx] = abs(data[idx]);
});
});
}
Expand All @@ -68,7 +68,7 @@ void outplace_absolute_array(std::shared_ptr<const DefaultExecutor> exec,
exec->get_queue()->submit([&](sycl::handler &cgh) {
cgh.parallel_for(sycl::range<1>{n}, [=](sycl::id<1> idx_id) {
const auto idx = idx_id[0];
out[idx] = dpcpp::abs(in[idx]);
out[idx] = abs(in[idx]);
});
});
}
Expand Down
1 change: 1 addition & 0 deletions dpcpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include(${PROJECT_SOURCE_DIR}/cmake/create_test.cmake)
set(GINKGO_COMPILING_DPCPP_TEST ON)

add_subdirectory(base)
add_subdirectory(components)
Expand Down
Loading