-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][ESIMD] Software-emulation preparation #2963
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
Merged
pvchupin
merged 1 commit into
intel:sycl
from
dongkyunahn-intel:private/dongkyun/esimd_cpu_emulation_new_header_files
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
sycl/include/CL/sycl/INTEL/esimd/detail/emu/esimd_emu_functions_v1.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//==----- esimd_emu_functions_v1.h - DPC++ Explicit SIMD API ---------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// \file esimd_emu_functions_v1.h | ||
/// | ||
/// \ingroup sycl_pi_esimd_cpu | ||
|
||
#pragma once | ||
|
||
// <cstdint> for 'uint32_t' type is included in upper-level device | ||
// interface file ('esimdcpu_device_interface.hpp') | ||
|
||
// This file defines function interfaces for ESIMD CPU Emulation | ||
// (ESIMD_CPU) to access LibCM CPU emulation functionalities from | ||
// kernel applications running under emulation | ||
|
||
// CM CPU Emulation Info : | ||
// https://github.com/intel/cm-cpu-emulation | ||
|
||
// Function pointers (*_ptr) with 'cm/__cm' prefixes correspond to | ||
// LibCM functions with same name | ||
// e.g.: cm_fence_ptr -> cm_fence() in LibCM | ||
|
||
// Function pointers (*_ptr) with 'sycl_' prefix correspond to LibCM | ||
// functions dedicated to SYCL support | ||
// e.g.: sycl_get_surface_base_addr_ptr | ||
// -> get_surface_base_addr(int) in LibCM | ||
|
||
/****** DO NOT MODIFY following function pointers ******/ | ||
/****** No reordering, No renaming, No removal ******/ | ||
|
||
// Intrinsics | ||
void (*cm_barrier_ptr)(void); | ||
void (*cm_sbarrier_ptr)(uint32_t); | ||
void (*cm_fence_ptr)(void); | ||
|
||
// libcm functionalities used for intrinsics such as | ||
// surface/buffer/slm access | ||
char *(*sycl_get_surface_base_addr_ptr)(int); | ||
char *(*__cm_emu_get_slm_ptr)(void); | ||
void (*cm_slm_init_ptr)(size_t); |
119 changes: 119 additions & 0 deletions
119
sycl/include/CL/sycl/INTEL/esimd/detail/emu/esimdcpu_device_interface.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
//==----- esimdcpu_device_interface.hpp - DPC++ Explicit SIMD API ---------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// \file esimdcpu_device_interface.hpp | ||
/// Declarations for ESIMD_CPU-device specific definitions. | ||
/// ESIMD intrinsic and LibCM functionalities required by intrinsic defined | ||
/// | ||
/// This interface is for ESIMD intrinsic emulation implementations | ||
/// such as slm_access to access ESIMD_CPU specific-support therefore | ||
/// it has to be defined and shared as include directory | ||
/// | ||
/// \ingroup sycl_pi_esimd_cpu | ||
|
||
#pragma once | ||
|
||
#include <CL/sycl/detail/pi.hpp> | ||
|
||
// cstdint-type fields such as 'uint32_t' are to be used in funtion | ||
// pointer table file ('esimd_emu_functions_v1.h') included in 'struct | ||
// ESIMDDeviceInterface' definition. | ||
#include <cstdint> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
|
||
/// This is the device interface version required (and used) by this | ||
/// implementation of the ESIMD CPU emulator. | ||
#define ESIMD_DEVICE_INTERFACE_VERSION 1 | ||
|
||
// 'ESIMDDeviceInterface' structure defines interface for ESIMD CPU | ||
// emulation (ESIMD_CPU) to access LibCM CPU emulation functionalities | ||
// from kernel application under emulation. | ||
|
||
romanovvlad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Header files included in the structure contains only function | ||
// pointers to access CM functionalities. Only new function can be | ||
// added - reordering, changing, or removing existing function pointer | ||
// is not allowed. | ||
|
||
// Whenever a new function(s) is added to this interface, a new header | ||
// file must be added following naming convention that contains | ||
// version number such as 'v1' from 'ESIMD_DEVICE_INTERFACE_VERSION'. | ||
struct ESIMDDeviceInterface { | ||
dongkyunahn-intel marked this conversation as resolved.
Show resolved
Hide resolved
dongkyunahn-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uintptr_t version; | ||
void *reserved; | ||
|
||
ESIMDDeviceInterface(); | ||
#include "esimd_emu_functions_v1.h" | ||
}; | ||
|
||
// Denotes the data version used by the implementation. | ||
// Increment whenever the 'data' field interpretation within PluginOpaqueData is | ||
// changed. | ||
#define ESIMD_EMU_PLUGIN_OPAQUE_DATA_VERSION 0 | ||
dongkyunahn-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// This structure denotes a ESIMD EMU plugin-specific data returned via the | ||
/// piextPluginGetOpaqueData PI call. Depending on the \c version field, the | ||
/// second \c data field can be interpreted differently. | ||
struct ESIMDEmuPluginOpaqueData { | ||
uintptr_t version; | ||
void *data; | ||
}; | ||
// The table below shows the correspondence between the \c version | ||
// and the contents of the \c data field: | ||
// version == 0, data is ESIMDDeviceInterface* | ||
|
||
dongkyunahn-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ESIMDDeviceInterface *getESIMDDeviceInterface() { | ||
romanovvlad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// TODO (performance) cache the interface pointer, can make a difference | ||
// when calling fine-grained libCM APIs through it (like memory access in a | ||
// tight loop) | ||
void *PIOpaqueData = nullptr; | ||
|
||
PIOpaqueData = getPluginOpaqueData<cl::sycl::backend::esimd_cpu>(nullptr); | ||
|
||
ESIMDEmuPluginOpaqueData *OpaqueData = | ||
reinterpret_cast<ESIMDEmuPluginOpaqueData *>(PIOpaqueData); | ||
|
||
// First check if opaque data version is compatible. | ||
if (OpaqueData->version != ESIMD_EMU_PLUGIN_OPAQUE_DATA_VERSION) { | ||
// NOTE: the version check should always be '!=' as layouts of different | ||
// versions of PluginOpaqueData is not backward compatible, unlike | ||
// layout of the ESIMDDeviceInterface. | ||
|
||
std::cerr << __FUNCTION__ << std::endl | ||
<< "Opaque data returned by ESIMD Emu plugin is incompatible with" | ||
<< "the one used in current implementation." << std::endl | ||
<< "Returned version : " << OpaqueData->version << std::endl | ||
<< "Required version : " << ESIMD_EMU_PLUGIN_OPAQUE_DATA_VERSION | ||
<< std::endl; | ||
throw cl::sycl::feature_not_supported(); | ||
} | ||
// Opaque data version is OK, can cast the 'data' field. | ||
ESIMDDeviceInterface *Interface = | ||
reinterpret_cast<ESIMDDeviceInterface *>(OpaqueData->data); | ||
|
||
// Now check that device interface version is compatible. | ||
if (Interface->version < ESIMD_DEVICE_INTERFACE_VERSION) { | ||
std::cerr << __FUNCTION__ << std::endl | ||
<< "The device interface version provided from plug-in " | ||
<< "library is behind required device interface version" | ||
<< std::endl | ||
<< "Found version : " << Interface->version << std::endl | ||
<< "Required version :" << ESIMD_DEVICE_INTERFACE_VERSION | ||
<< std::endl; | ||
throw cl::sycl::feature_not_supported(); | ||
} | ||
return Interface; | ||
} | ||
|
||
#undef ESIMD_DEVICE_INTERFACE_VERSION | ||
#undef ESIMD_EMU_PLUGIN_OPAQUE_DATA_VERSION | ||
|
||
} // namespace detail | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# PI Esimd CPU library | ||
# Create Shared library for libpi_esimd_cpu.so. | ||
|
||
include_directories("${sycl_inc_dir}") | ||
include_directories(${OpenCL_INCLUDE_DIR}) | ||
include_directories(${LIBCMRT_INCLUDE}) | ||
dongkyunahn-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
add_library(pi_esimd_cpu SHARED | ||
"${sycl_inc_dir}/CL/sycl/detail/pi.h" | ||
"pi_esimd_cpu.cpp" | ||
) | ||
|
||
if (MSVC) | ||
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport) | ||
# which are individually tagged for all pi* symbols in pi.h | ||
target_compile_definitions(pi_esimd_cpu PRIVATE __SYCL_BUILD_SYCL_DLL) | ||
else() | ||
# we set the visibility of all symbols 'hidden' by default. | ||
# In pi.h file, we set exported symbols with visibility==default individually | ||
target_compile_options(pi_esimd_cpu PUBLIC -fvisibility=hidden) | ||
|
||
# This script file is used to allow exporting pi* symbols only. | ||
# All other symbols are regarded as local (hidden) | ||
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt") | ||
|
||
# Filter symbols based on the scope defined in the script file, | ||
# and export pi* function symbols in the library. | ||
target_link_libraries( pi_esimd_cpu | ||
PRIVATE "-Wl,--version-script=${linker_script}" | ||
) | ||
endif() | ||
|
||
add_dependencies(sycl-toolchain pi_esimd_cpu) | ||
|
||
add_dependencies(pi_esimd_cpu | ||
OpenCL-Headers) | ||
|
||
target_link_libraries(pi_esimd_cpu PRIVATE sycl) | ||
set_target_properties(pi_esimd_cpu PROPERTIES LINKER_LANGUAGE CXX) | ||
|
||
add_common_options(pi_esimd_cpu) | ||
|
||
install(TARGETS pi_esimd_cpu | ||
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_esimd_cpu | ||
RUNTIME DESTINATION "bin" COMPONENT pi_esimd_cpu) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.