Skip to content
Closed
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
87 changes: 39 additions & 48 deletions backends/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
string(COMPARE EQUAL "${GTEST_INCLUDE_DIR}" "" no_gtest_incl_dir)
string(COMPARE EQUAL "${GTEST_LIB_DIR}" "" no_gtest_lib_dir)

if(${no_gtest_incl_dir} OR ${no_gtest_lib_dir})
message(WARNING
"GTest is needed to test dpCtl's C API test cases. Pass in \
-DGTEST_INCLUDE_DIR and -DGTEST_LIB_DIR when you configure Cmake if\
you wish to run dpCtl backend tests."
)
else()
# We need thread support for gtest
find_package(Threads REQUIRED)

set(CMAKE_CTEST_COMMAND ctest -V)

# Emulate autotools like make check target to build tests
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
enable_testing()

include_directories(${GTEST_INCLUDE_DIR})
include_directories(../include)

link_directories(${GTEST_LIB_DIR})

set(DPCTL_C_API_TEST_CASES
test_sycl_kernel_interface
test_sycl_platform_interface
test_sycl_program_interface
test_sycl_queue_interface
test_sycl_queue_manager
find_package(GTest REQUIRED)

# We need thread support for gtest
find_package(Threads REQUIRED)

set(CMAKE_CTEST_COMMAND ctest -V)

# Emulate autotools like make check target to build tests
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
enable_testing()
Comment thread
PokhodenkoSA marked this conversation as resolved.
Resolved

include_directories(${GTEST_INCLUDE_DIR})
include_directories(../include)

link_directories(${GTEST_LIB_DIR})

set(PYDPPL_BACKEND_TEST_CASES
test_sycl_kernel_interface
test_sycl_platform_interface
test_sycl_program_interface
test_sycl_queue_interface
test_sycl_queue_manager
)

# Copy the spir-v input files to test build directory
set(spirv-test-files
multi_kernel.spv
)
foreach(tf ${spirv-test-files})
file(COPY ${tf} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endforeach()

foreach(TEST_CASE ${PYDPPL_BACKEND_TEST_CASES})
add_executable(${TEST_CASE} EXCLUDE_FROM_ALL ${TEST_CASE}.cpp)
target_link_libraries(
${TEST_CASE} ${CMAKE_THREAD_LIBS_INIT} GTest::GTest DPPLSyclInterface
)

# Copy the spir-v input files to test build directory
set(spirv-test-files
multi_kernel.spv
)
foreach(tf ${spirv-test-files})
file(COPY ${tf} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endforeach()

foreach(TEST_CASE ${DPCTL_C_API_TEST_CASES})
add_executable(${TEST_CASE} EXCLUDE_FROM_ALL ${TEST_CASE}.cpp)
target_link_libraries(
${TEST_CASE} ${CMAKE_THREAD_LIBS_INIT} gtest DPPLSyclInterface
)
add_test(NAME ${TEST_CASE} COMMAND ${TEST_CASE})
add_dependencies(check ${TEST_CASE})
endforeach()
endif()
add_test(NAME ${TEST_CASE} COMMAND ${TEST_CASE})
add_dependencies(check ${TEST_CASE})
endforeach()
5 changes: 3 additions & 2 deletions backends/tests/test_sycl_program_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@

#include <array>
#include <fstream>
#include <filesystem>
#include <experimental/filesystem>
#include <gtest/gtest.h>
#include <CL/sycl.hpp>

using namespace cl::sycl;
using fs = std::experimental::filesystem;

namespace
{
Expand Down Expand Up @@ -130,7 +131,7 @@ struct TestDPPLSyclProgramInterface : public ::testing::Test
TestDPPLSyclProgramInterface () :
nOpenCLGpuQ(DPPLQueueMgr_GetNumQueues(DPPL_OPENCL, DPPL_GPU)),
spirvFile{"./multi_kernel.spv", std::ios::binary | std::ios::ate},
spirvFileSize(std::filesystem::file_size("./multi_kernel.spv")),
spirvFileSize(fs::file_size("./multi_kernel.spv")),
spirvBuffer(spirvFileSize)
{
spirvFile.seekg(0, std::ios::beg);
Expand Down
3 changes: 3 additions & 0 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ cmake -G Ninja ^
IF %ERRORLEVEL% NEQ 0 exit 1

ninja -n
IF %ERRORLEVEL% NEQ 0 exit 1
ninja check
IF %ERRORLEVEL% NEQ 0 exit 1
ninja install
IF %ERRORLEVEL% NEQ 0 exit 1

Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cmake \
-DNUMPY_INCLUDE_DIR=${NUMPY_INC} \
../backends

make -j 4 && make install
make -j 4 && make check && make install

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
make -j 4 && make check && make install
make -j 4
make check
make install


popd
cp install/lib/*.so dpctl/
Expand Down
1 change: 1 addition & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ requirements:
- make # [unix]
- ninja # [win]
- numpy >=1.17
- gtest
run:
- python
- numpy >=1.17
Expand Down