Skip to content

Commit 5ca2386

Browse files
[SYCL][ESIMD] Software-emulation preparation
* This PR adds new Plug-In module for ESIMD Software-emulation, ESIMD_CPU * The new feature will use CM emulation library for runtime support and ESIMD intrinsics such as Software-multithreaded kernel launching and buffer management/access * pi* functions are filled with dummy codes as placeholder * Steps for importing CM will be added later * Two PI APIs are added - piextGetPluginSpecificData, piEnqueueHostKernelLaunch
1 parent b2e4a83 commit 5ca2386

File tree

11 files changed

+1457
-0
lines changed

11 files changed

+1457
-0
lines changed

buildbot/configure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def do_configure(args):
2727
llvm_enable_projects = 'clang;' + llvm_external_projects
2828
libclc_targets_to_build = ''
2929
sycl_build_pi_cuda = 'OFF'
30+
sycl_build_pi_esimd_cpu = 'ON'
3031
sycl_werror = 'ON'
3132
llvm_enable_assertions = 'ON'
3233
llvm_enable_doxygen = 'OFF'
@@ -46,6 +47,9 @@ def do_configure(args):
4647
libclc_targets_to_build = 'nvptx64--;nvptx64--nvidiacl'
4748
sycl_build_pi_cuda = 'ON'
4849

50+
if args.disable_esimd_cpu:
51+
sycl_build_pi_esimd_cpu = 'OFF'
52+
4953
if args.no_werror:
5054
sycl_werror = 'OFF'
5155

@@ -84,6 +88,7 @@ def do_configure(args):
8488
"-DLLVM_ENABLE_DOXYGEN={}".format(llvm_enable_doxygen),
8589
"-DLLVM_ENABLE_SPHINX={}".format(llvm_enable_sphinx),
8690
"-DBUILD_SHARED_LIBS={}".format(llvm_build_shared_libs),
91+
"-DSYCL_BUILD_PI_ESIMD_CPU={}".format(sycl_build_pi_esimd_cpu),
8792
"-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing)
8893
]
8994

@@ -148,6 +153,7 @@ def main():
148153
metavar="BUILD_TYPE", default="Release", help="build type: Debug, Release")
149154
parser.add_argument("--cuda", action='store_true', help="switch from OpenCL to CUDA")
150155
parser.add_argument("--arm", action='store_true', help="build ARM support rather than x86")
156+
parser.add_argument("--disable-esimd-cpu", action='store_true', help="build without ESIMD_CPU support")
151157
parser.add_argument("--no-assertions", action='store_true', help="build without assertions")
152158
parser.add_argument("--docs", action='store_true', help="build Doxygen documentation")
153159
parser.add_argument("--system-ocl", action='store_true', help="use OpenCL deps from system (no download)")

sycl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS
357357
sycl
358358
pi_opencl
359359
pi_level_zero
360+
pi_esimd_cpu
360361
libsycldevice
361362
${XPTIFW_LIBS}
362363
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//==----- esimdcpu_device_interface.hpp - DPC++ Explicit SIMD API ---------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
/// \file esimdcpu_device_interface.hpp
10+
/// Declarations for ESIMD_CPU-device specific definitions.
11+
/// ESIMD intrinsic and LibCM functionalities required by intrinsic defined
12+
///
13+
/// \ingroup sycl_pi_esimd_cpu
14+
15+
#pragma once
16+
17+
#include <cstdint>
18+
19+
#ifdef _MSC_VER
20+
typedef unsigned int uint;
21+
typedef unsigned short ushort;
22+
typedef unsigned char uchar;
23+
#endif // _MSC_VER
24+
25+
struct ESIMDDeviceInterface {
26+
27+
// Intrinsics
28+
virtual void mt_barrier() = 0;
29+
virtual void split_barrier(uint) = 0;
30+
virtual void fence() = 0;
31+
32+
// libcm functionalities used for intrinsics such as
33+
// surface/buffer/slm access
34+
virtual char *get_surface_base(int surfaceID) = 0;
35+
virtual char *get_slm() = 0;
36+
virtual void set_slm_size(size_t size) = 0;
37+
};

sycl/include/CL/sycl/detail/pi.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ _PI_API(piextDeviceSelectBinary)
2929
_PI_API(piextGetDeviceFunctionPointer)
3030
_PI_API(piextDeviceGetNativeHandle)
3131
_PI_API(piextDeviceCreateWithNativeHandle)
32+
_PI_API(piextGetPluginSpecificData)
3233
// Context
3334
_PI_API(piContextCreate)
3435
_PI_API(piContextGetInfo)
@@ -97,6 +98,7 @@ _PI_API(piSamplerRetain)
9798
_PI_API(piSamplerRelease)
9899
// Queue commands
99100
_PI_API(piEnqueueKernelLaunch)
101+
_PI_API(piEnqueueHostKernelLaunch)
100102
_PI_API(piEnqueueNativeKernel)
101103
_PI_API(piEnqueueEventsWait)
102104
_PI_API(piEnqueueEventsWaitWithBarrier)

sycl/include/CL/sycl/detail/pi.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,9 @@ piextDeviceGetNativeHandle(pi_device device, pi_native_handle *nativeHandle);
913913
__SYCL_EXPORT pi_result piextDeviceCreateWithNativeHandle(
914914
pi_native_handle nativeHandle, pi_platform platform, pi_device *device);
915915

916+
/// Returns plug-in specific data
917+
__SYCL_EXPORT pi_result piextGetPluginSpecificData(void **PlugInData);
918+
916919
/// Selects the most appropriate device binary based on runtime information
917920
/// and the IR characteristics.
918921
///
@@ -1309,6 +1312,12 @@ __SYCL_EXPORT pi_result piEnqueueKernelLaunch(
13091312
const size_t *local_work_size, pi_uint32 num_events_in_wait_list,
13101313
const pi_event *event_wait_list, pi_event *event);
13111314

1315+
__SYCL_EXPORT pi_result piEnqueueHostKernelLaunch(
1316+
void *Kernel, pi_uint32 WorkDim, const size_t *GlobalWorkOffset,
1317+
const size_t *GlobalWorkSize, const size_t *LocalWorkSize,
1318+
pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList,
1319+
pi_event *Event);
1320+
13121321
__SYCL_EXPORT pi_result piEnqueueNativeKernel(
13131322
pi_queue queue, void (*user_func)(void *), void *args, size_t cb_args,
13141323
pi_uint32 num_mem_objects, const pi_mem *mem_list,

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,19 @@ enum TraceLevel {
5757
// Return true if we want to trace PI related activities.
5858
bool trace(TraceLevel level);
5959

60+
// Return PluginSpecificData referenced by kernel code
61+
__SYCL_EXPORT void *getPluginSpecificData(backend be);
62+
6063
#ifdef __SYCL_RT_OS_WINDOWS
6164
#define __SYCL_OPENCL_PLUGIN_NAME "pi_opencl.dll"
6265
#define __SYCL_LEVEL_ZERO_PLUGIN_NAME "pi_level_zero.dll"
6366
#define __SYCL_CUDA_PLUGIN_NAME "pi_cuda.dll"
67+
#define __SYCL_ESIMD_CPU_PLUGIN_NAME "pi_esimd_cpu.dll"
6468
#else
6569
#define __SYCL_OPENCL_PLUGIN_NAME "libpi_opencl.so"
6670
#define __SYCL_LEVEL_ZERO_PLUGIN_NAME "libpi_level_zero.so"
6771
#define __SYCL_CUDA_PLUGIN_NAME "libpi_cuda.so"
72+
#define __SYCL_ESIMD_CPU_PLUGIN_NAME "libpi_esimd_cpu.so"
6873
#endif
6974

7075
// Report error and no return (keeps compiler happy about no return statements).

sycl/plugins/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ endif()
1010

1111
add_subdirectory(opencl)
1212
add_subdirectory(level_zero)
13+
14+
if (SYCL_BUILD_PI_ESIMD_CPU)
15+
add_subdirectory(esimd_cpu)
16+
endif()

sycl/plugins/esimd_cpu/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# PI Esimd CPU library
3+
# Create Shared library for libpi_esimd_cpu.so.
4+
5+
include_directories("${sycl_inc_dir}")
6+
include_directories(${OPENCL_INCLUDE})
7+
include_directories(${LIBCMRT_INCLUDE})
8+
9+
add_library(pi_esimd_cpu SHARED
10+
"${sycl_inc_dir}/CL/sycl/detail/pi.h"
11+
"pi_esimd_cpu.cpp"
12+
)
13+
14+
add_dependencies(sycl-toolchain pi_esimd_cpu)
15+
16+
add_dependencies(pi_esimd_cpu
17+
ocl-headers)
18+
19+
target_link_libraries(pi_esimd_cpu PRIVATE sycl ${CMAKE_DL_LIBS})
20+
set_target_properties(pi_esimd_cpu PROPERTIES LINKER_LANGUAGE CXX)
21+
22+
add_common_options(pi_esimd_cpu)
23+
24+
install(TARGETS pi_esimd_cpu
25+
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_esimd_cpu
26+
RUNTIME DESTINATION "bin" COMPONENT pi_esimd_cpu)

0 commit comments

Comments
 (0)