Skip to content

Commit 183caf3

Browse files
authored
[SYCL][XPTI] Enable XPTI tests (#4545)
- Fix XPTI libraries deployment locations in CMake - Fix incorrect definitions and options in CMake - Enable -Werror for XPTI by default - Add LLVM-style target check-xptifw - Run check-xptifw by default in GitHub Actions post-commit job - Fix whatever warnings the compiler complained about.
1 parent 1717a14 commit 183caf3

32 files changed

+342
-231
lines changed

.github/workflows/linux_post_commit.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ jobs:
7878
run: |
7979
python3 $GITHUB_WORKSPACE/src/buildbot/check.py -w $GITHUB_WORKSPACE \
8080
-s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t check-llvm-spirv
81+
- name: check-xptifw
82+
if: always()
83+
run: |
84+
python3 $GITHUB_WORKSPACE/src/buildbot/check.py -w $GITHUB_WORKSPACE \
85+
-s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t check-xptifw
8186
- name: Pack
8287
run: tar -czvf llvm_sycl.tar.gz -C $GITHUB_WORKSPACE/build/install .
8388
- name: Upload artifacts

buildbot/configure.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def do_configure(args):
4040
llvm_enable_lld = 'OFF'
4141

4242
sycl_enable_xpti_tracing = 'ON'
43+
xpti_enable_werror = 'ON'
4344

4445
if args.ci_defaults:
4546
print("#############################################")
@@ -79,6 +80,7 @@ def do_configure(args):
7980

8081
if args.no_werror:
8182
sycl_werror = 'OFF'
83+
xpti_enable_werror = 'OFF'
8284

8385
if args.no_assertions:
8486
llvm_enable_assertions = 'OFF'
@@ -123,7 +125,8 @@ def do_configure(args):
123125
"-DBUILD_SHARED_LIBS={}".format(llvm_build_shared_libs),
124126
"-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing),
125127
"-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld),
126-
"-DSYCL_BUILD_PI_ESIMD_CPU={}".format(sycl_build_pi_esimd_cpu)
128+
"-DSYCL_BUILD_PI_ESIMD_CPU={}".format(sycl_build_pi_esimd_cpu),
129+
"-DXPTI_ENABLE_WERROR={}".format(xpti_enable_werror)
127130
]
128131

129132
if args.l0_headers and args.l0_loader:

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ if (NOT WIN32)
172172
endif()
173173

174174
if (SYCL_ENABLE_XPTI_TRACING)
175-
set(XPTIFW_LIBS xptifw)
175+
set(XPTIFW_LIBS xpti xptifw)
176176
endif()
177177

178178
# SYCL toolchain builds all components: compiler, libraries, headers, etc.

sycl/source/detail/event_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <chrono>
1919

2020
#ifdef XPTI_ENABLE_INSTRUMENTATION
21-
#include "xpti_trace_framework.hpp"
21+
#include "xpti/xpti_trace_framework.hpp"
2222
#include <atomic>
2323
#include <detail/xpti_registry.hpp>
2424
#include <sstream>

sycl/source/detail/pi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#ifdef XPTI_ENABLE_INSTRUMENTATION
3636
// Include the headers necessary for emitting
3737
// traces using the trace framework
38-
#include "xpti_trace_framework.h"
38+
#include "xpti/xpti_trace_framework.h"
3939
#endif
4040

4141
#define STR(x) #x

sycl/source/detail/plugin.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#ifdef XPTI_ENABLE_INSTRUMENTATION
2020
// Include the headers necessary for emitting traces using the trace framework
21-
#include "xpti_trace_framework.h"
21+
#include "xpti/xpti_trace_framework.h"
2222
#endif
2323

2424
__SYCL_INLINE_NAMESPACE(cl) {

sycl/source/detail/queue_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <utility>
1818

1919
#ifdef XPTI_ENABLE_INSTRUMENTATION
20-
#include "xpti_trace_framework.hpp"
20+
#include "xpti/xpti_trace_framework.hpp"
2121
#include <detail/xpti_registry.hpp>
2222
#include <sstream>
2323
#endif

sycl/source/detail/scheduler/commands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#endif
4444

4545
#ifdef XPTI_ENABLE_INSTRUMENTATION
46-
#include "xpti_trace_framework.hpp"
46+
#include "xpti/xpti_trace_framework.hpp"
4747
#include <detail/xpti_registry.hpp>
4848
#endif
4949

sycl/source/detail/xpti_registry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifdef XPTI_ENABLE_INSTRUMENTATION
1515
// Include the headers necessary for emitting
1616
// traces using the trace framework
17-
#include "xpti_trace_framework.h"
17+
#include "xpti/xpti_trace_framework.h"
1818
#endif
1919

2020
__SYCL_INLINE_NAMESPACE(cl) {

sycl/tools/pi-trace/pi_trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/// A sample XPTI subscriber to demonstrate how to collect PI function call
1111
/// arguments.
1212

13-
#include "xpti_trace_framework.h"
13+
#include "xpti/xpti_trace_framework.h"
1414

1515
#include "pi_arguments_handler.hpp"
1616

xpti/CMakeLists.txt

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
cmake_minimum_required(VERSION 2.8.9)
1+
cmake_minimum_required(VERSION 3.8)
22

33
set(XPTI_VERSION 0.4.1)
4+
project (xpti VERSION "${XPTI_VERSION}" LANGUAGES CXX)
5+
set(CMAKE_CXX_STANDARD 14)
6+
47
set(XPTI_DIR ${CMAKE_CURRENT_LIST_DIR})
58
# Setting the same version as SYCL
69
set(CMAKE_CXX_STANDARD 11)
710

11+
option(XPTI_ENABLE_WERROR OFF)
12+
13+
if (XPTI_ENABLE_WERROR)
14+
if(MSVC)
15+
set(CMAKE_CXX_FLAGS "/WX ${CMAKE_CXX_FLAGS}")
16+
else()
17+
set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
18+
endif()
19+
endif()
20+
821
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
922
message(STATUS "No build type selected, default to Release")
1023
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE)
1124
endif()
1225

13-
project (xpti)
14-
1526
if (MSVC)
1627
# MSVC provides two incompatible build variants for its CRT: release and debug
1728
# To avoid potential issues in user code we also need to provide two kinds
@@ -63,5 +74,20 @@ set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/lib/${CMAKE_BUILD_TYPE})
6374
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
6475
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
6576

66-
include_directories(${CMAKE_SOURCE_DIR}/include)
6777
add_subdirectory(src)
78+
79+
if (LLVM_BINARY_DIR)
80+
add_custom_target(xpti-headers ALL
81+
COMMAND ${CMAKE_COMMAND} -E copy_directory
82+
${CMAKE_CURRENT_SOURCE_DIR}/include/xpti
83+
${LLVM_BINARY_DIR}/include/xpti
84+
COMMENT "Copying XPTI headers..."
85+
)
86+
add_dependencies(xpti xpti-headers)
87+
endif()
88+
89+
include(GNUInstallDirs)
90+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/xpti
91+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
92+
COMPONENT xpti
93+
)
File renamed without changes.

xpti/include/xpti_trace_framework.h renamed to xpti/include/xpti/xpti_trace_framework.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
//
77
//
88
#pragma once
9-
#include "xpti_data_types.h"
9+
10+
#include "xpti/xpti_data_types.h"
1011

1112
#if defined(XPTI_STATIC_LIBRARY)
1213
// If we are building or using the proxy

xpti/include/xpti_trace_framework.hpp renamed to xpti/include/xpti/xpti_trace_framework.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@
66
//
77
//
88
#pragma once
9+
910
#include <cstdint>
1011
#include <memory>
1112
#include <sstream>
1213
#include <thread>
1314

14-
#include "xpti_data_types.h"
15-
#include "xpti_trace_framework.h"
15+
#include "xpti/xpti_data_types.h"
16+
#include "xpti/xpti_trace_framework.h"
1617

1718
#if defined(_WIN32) || defined(_WIN64)
1819
#include <string>
1920
#include <strsafe.h>
21+
// Windows.h defines min and max macros, that interfere with C++ std::min and
22+
// std::max. The following definition disables that feature.
23+
#define NOMINMAX
2024
#include <windows.h>
25+
#undef NOMINMAX
2126
typedef HINSTANCE xpti_plugin_handle_t;
2227
typedef FARPROC xpti_plugin_function_t;
2328
#define XPTI_PLUGIN_STRING "*.dll"

xpti/src/CMakeLists.txt

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1-
cmake_minimum_required(VERSION 2.8.9)
2-
project (xpti)
3-
file(GLOB SOURCES *.cpp)
4-
include_directories(${XPTI_DIR}/include)
5-
add_definitions(-DXPTI_STATIC_LIBRARY)
6-
add_library(xpti STATIC ${SOURCES})
1+
include(GNUInstallDirs)
2+
3+
macro(add_xpti_lib target_name)
4+
add_library(${target_name} STATIC ${ARGN})
5+
target_compile_definitions(${target_name} PRIVATE -DXPTI_STATIC_LIBRARY)
6+
target_include_directories(${target_name} PRIVATE ${XPTI_DIR}/include)
7+
8+
if (MSVC)
9+
target_compile_options(${target_name} PRIVATE /EHsc)
10+
endif()
11+
12+
# Set the location of the library installation
13+
install(TARGETS ${target_name}
14+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT xpti
15+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT xpti
16+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT xpti
17+
)
18+
endmacro()
19+
20+
set(SOURCES
21+
xpti_proxy.cpp
22+
)
23+
24+
add_xpti_lib(xpti ${SOURCES})
725

826
# Handle the debug version for the Microsoft compiler as a special case by
927
# creating a debug version of the static library that uses the flags used by
1028
# the SYCL runtime
1129
if (MSVC)
12-
add_library(xptid STATIC ${SOURCES})
30+
add_xpti_lib(xptid STATIC ${SOURCES})
1331
target_compile_options(xptid PRIVATE ${XPTI_CXX_FLAGS_DEBUG})
1432
target_compile_options(xpti PRIVATE ${XPTI_CXX_FLAGS_RELEASE})
1533
endif()
1634

17-
# Set the location of the library installation
18-
install(TARGETS xpti DESTINATION ${CMAKE_BINARY_DIR})

xpti/src/xpti_proxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//
8-
#include "xpti_trace_framework.hpp"
8+
#include "xpti/xpti_trace_framework.hpp"
99

1010
#include <iostream>
1111
#include <memory>

xptifw/CMakeLists.txt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8)
33
set(XPTI_VERSION 0.4.1)
44

55
project (xptifw VERSION "${XPTI_VERSION}" LANGUAGES CXX)
6+
set(CMAKE_CXX_STANDARD 14)
67

78
set(XPTIFW_DIR ${CMAKE_CURRENT_LIST_DIR})
89
# The XPTI framework requires the includes from
@@ -12,15 +13,24 @@ set(XPTI_DIR ${CMAKE_CURRENT_LIST_DIR}/../xpti)
1213
# Create a soft option for enabling the use of TBB
1314
option(XPTI_ENABLE_TBB "Enable TBB in the framework" OFF)
1415

16+
option(XPTI_ENABLE_WERROR OFF)
17+
18+
if (XPTI_ENABLE_WERROR)
19+
if(MSVC)
20+
set(CMAKE_CXX_FLAGS "/WX ${CMAKE_CXX_FLAGS}")
21+
else()
22+
set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
23+
endif()
24+
endif()
25+
1526
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1627
message(STATUS "No build type selected, default to Release")
1728
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE)
1829
endif()
1930

2031
if(MSVC)
21-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
32+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
2233
endif()
23-
2434
if (SYCL_USE_LIBCXX)
2535
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
2636
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
@@ -38,20 +48,16 @@ set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/lib/${CMAKE_BUILD_TYPE})
3848
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
3949
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
4050

41-
include_directories(${CMAKE_SOURCE_DIR}/include ${XPTI_DIR}/include)
4251
add_subdirectory(src)
43-
# TODO enable samples and tests back once build problems are resolved.
44-
# Currently builds for unit tests and samples fail mostly with dllimport/dllexport
45-
# mismatch problems:
46-
# syclpi_collector.cpp(32): error C2491: 'xptiTraceInit': definition of dllimport function not allowed
47-
if (0)
52+
53+
add_custom_target(check-xptifw)
54+
4855
add_subdirectory(unit_test)
4956
add_subdirectory(samples/basic_collector)
5057
add_subdirectory(samples/syclpi_collector)
51-
endif()
5258

5359
# The tests in basic_test are written using TBB, so these tests are enabled
5460
# only if TBB has been enabled.
55-
if (0)
61+
if (XPTI_ENABLE_TBB)
5662
add_subdirectory(basic_test)
5763
endif()

xptifw/basic_test/CMakeLists.txt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
cmake_minimum_required(VERSION 2.8.9)
2-
project (run_test)
3-
41
file(GLOB SOURCES *.cpp *.hpp)
52
include_directories(${XPTIFW_DIR}/include)
63
include_directories(${XPTI_DIR}/include)
74

8-
remove_definitions(-DXPTI_STATIC_LIBRARY)
9-
add_definitions(-DXPTI_API_EXPORTS -g -O3)
10-
add_executable(run_test ${SOURCES})
11-
add_dependencies(run_test xptifw)
12-
target_link_libraries(run_test PRIVATE xptifw)
13-
if(UNIX)
14-
target_link_libraries(run_test PRIVATE dl)
15-
endif()
5+
add_executable(XPTIFWBasicTests ${SOURCES})
6+
target_link_libraries(XPTIFWBasicTests PRIVATE xptifw ${CMAKE_DL_LIBS})
167

17-
if (XPTI_ENABLE_TBB)
18-
target_link_libraries(run_test PRIVATE tbb)
8+
if (UNIX)
9+
target_compile_definitions(XPTIFWBasicTests PRIVATE -gline-tables-only -O3)
1910
endif()
2011

21-
# Set the location of the library installation
22-
install(TARGETS run_test DESTINATION ${CMAKE_BINARY_DIR})
12+
# There's a XPTI_ENABLE_TBB guard in xptifw/CMakeLists.txt
13+
target_link_libraries(XPTIFWBasicTests PRIVATE tbb)
14+
15+
# Override default LLVM bin location
16+
set_target_properties(XPTIFWBasicTests
17+
PROPERTIES
18+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
19+
)
20+
21+
add_custom_target(check-xptifw-basictest COMMAND
22+
$<TARGET_PROPERTY:XPTIFWBasicTests,RUNTIME_OUTPUT_DIRECTORY>/XPTIFWBasicTests)
23+
add_dependencies(check-xptifw-basictest XPTIFWBasicTests)
24+
add_dependencies(check-xptifw check-xptifw-basictest)

xptifw/basic_test/cl_processor.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
//
77
//
88
#pragma once
9-
#include "xpti_trace_framework.hpp"
9+
10+
#include "xpti/xpti_trace_framework.hpp"
1011

1112
#include <chrono>
1213
#include <iomanip>

xptifw/basic_test/performance_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "tbb/task_group.h"
1818

1919
#include "cl_processor.hpp"
20-
#include "xpti_trace_framework.h"
20+
#include "xpti/xpti_trace_framework.h"
2121

2222
#include <atomic>
2323
#include <chrono>

xptifw/basic_test/semantic_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "tbb/task_group.h"
1717

1818
#include "cl_processor.hpp"
19-
#include "xpti_trace_framework.h"
19+
#include "xpti/xpti_trace_framework.h"
2020

2121
#include <atomic>
2222
#include <chrono>

xptifw/include/xpti_int64_hash_table.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
//
66
#pragma once
7-
#include "xpti_data_types.h"
7+
8+
#include "xpti/xpti_data_types.h"
89

910
#include <atomic>
1011
#include <mutex>

0 commit comments

Comments
 (0)