Skip to content
Merged
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
1 change: 1 addition & 0 deletions sycl/include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <CL/sycl/atomic.hpp>
#include <CL/sycl/buffer.hpp>
#include <CL/sycl/detail/accessor_impl.hpp>
#include <CL/sycl/detail/cl.h>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/generic_type_traits.hpp>
Expand Down
1 change: 1 addition & 0 deletions sycl/include/CL/sycl/aliases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <CL/sycl/detail/cl.h>
#include <CL/sycl/detail/common.hpp>

#include <cstddef>
Expand Down
1 change: 1 addition & 0 deletions sycl/include/CL/sycl/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <CL/__spirv/spirv_ops.hpp>
#include <CL/sycl/access/access.hpp>
#include <CL/sycl/detail/cl.h>
#include <CL/sycl/detail/helpers.hpp>
#include <CL/sycl/memory_enums.hpp>

Expand Down
1 change: 1 addition & 0 deletions sycl/include/CL/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <CL/sycl/detail/backend_traits.hpp>
#include <CL/sycl/detail/cl.h>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/stl_type_traits.hpp>
Expand Down
46 changes: 23 additions & 23 deletions sycl/include/CL/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#pragma once

#include <CL/sycl/detail/cl.h>
#include <CL/sycl/detail/defines.hpp>
#include <CL/sycl/detail/defines_elementary.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/pi.hpp>
#include <CL/sycl/detail/stl_type_traits.hpp>

#include <cstdint>
Expand Down Expand Up @@ -91,9 +91,9 @@ __SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

__SYCL_EXPORT const char *stringifyErrorCode(cl_int error);
__SYCL_EXPORT const char *stringifyErrorCode(pi_int32 error);

static inline std::string codeToString(cl_int code) {
static inline std::string codeToString(pi_int32 code) {
return std::string(std::to_string(code) + " (" + stringifyErrorCode(code) +
")");
}
Expand All @@ -109,20 +109,20 @@ static inline std::string codeToString(cl_int code) {
#define __SYCL_ASSERT(x) assert(x)
#endif // #ifdef __SYCL_DEVICE_ONLY__

#define __SYCL_OCL_ERROR_REPORT \
#define __SYCL_PI_ERROR_REPORT \
"Native API failed. " /*__FILE__*/ \
/* TODO: replace __FILE__ to report only relative path*/ \
/* ":" __SYCL_STRINGIFY(__LINE__) ": " */ \
"Native API returns: "

#ifndef __SYCL_SUPPRESS_OCL_ERROR_REPORT
#ifndef __SYCL_SUPPRESS_PI_ERROR_REPORT
#include <iostream>
// TODO: rename all names with direct use of OCL/OPENCL to be backend agnostic.
#define __SYCL_REPORT_OCL_ERR_TO_STREAM(expr) \
#define __SYCL_REPORT_PI_ERR_TO_STREAM(expr) \
{ \
auto code = expr; \
if (code != CL_SUCCESS) { \
std::cerr << __SYCL_OCL_ERROR_REPORT \
if (code != PI_SUCCESS) { \
std::cerr << __SYCL_PI_ERROR_REPORT \
<< cl::sycl::detail::codeToString(code) << std::endl; \
} \
}
Expand All @@ -131,39 +131,39 @@ static inline std::string codeToString(cl_int code) {
#ifndef SYCL_SUPPRESS_EXCEPTIONS
#include <CL/sycl/exception.hpp>
// SYCL 1.2.1 exceptions
#define __SYCL_REPORT_OCL_ERR_TO_EXC(expr, exc, str) \
#define __SYCL_REPORT_PI_ERR_TO_EXC(expr, exc, str) \
{ \
auto code = expr; \
if (code != CL_SUCCESS) { \
if (code != PI_SUCCESS) { \
std::string err_str = \
str ? "\n" + std::string(str) + "\n" : std::string{}; \
throw exc(__SYCL_OCL_ERROR_REPORT + \
throw exc(__SYCL_PI_ERROR_REPORT + \
cl::sycl::detail::codeToString(code) + err_str, \
code); \
} \
}
#define __SYCL_REPORT_OCL_ERR_TO_EXC_THROW(code, exc, str) \
__SYCL_REPORT_OCL_ERR_TO_EXC(code, exc, str)
#define __SYCL_REPORT_OCL_ERR_TO_EXC_BASE(code) \
__SYCL_REPORT_OCL_ERR_TO_EXC(code, cl::sycl::runtime_error, nullptr)
#define __SYCL_REPORT_PI_ERR_TO_EXC_THROW(code, exc, str) \
__SYCL_REPORT_PI_ERR_TO_EXC(code, exc, str)
#define __SYCL_REPORT_PI_ERR_TO_EXC_BASE(code) \
__SYCL_REPORT_PI_ERR_TO_EXC(code, cl::sycl::runtime_error, nullptr)
#else
#define __SYCL_REPORT_OCL_ERR_TO_EXC_BASE(code) \
__SYCL_REPORT_OCL_ERR_TO_STREAM(code)
#define __SYCL_REPORT_PI_ERR_TO_EXC_BASE(code) \
__SYCL_REPORT_PI_ERR_TO_STREAM(code)
#endif
// SYCL 2020 exceptions
#define __SYCL_REPORT_ERR_TO_EXC_VIA_ERRC(expr, errc) \
{ \
auto code = expr; \
if (code != CL_SUCCESS) { \
if (code != PI_SUCCESS) { \
throw sycl::exception(sycl::make_error_code(errc), \
__SYCL_OCL_ERROR_REPORT + \
__SYCL_PI_ERROR_REPORT + \
cl::sycl::detail::codeToString(code)); \
} \
}
#define __SYCL_REPORT_ERR_TO_EXC_THROW_VIA_ERRC(code, errc) \
__SYCL_REPORT_ERR_TO_EXC_VIA_ERRC(code, errc)

#ifdef __SYCL_SUPPRESS_OCL_ERROR_REPORT
#ifdef __SYCL_SUPPRESS_PI_ERROR_REPORT
// SYCL 1.2.1 exceptions
#define __SYCL_CHECK_OCL_CODE(X) (void)(X)
#define __SYCL_CHECK_OCL_CODE_THROW(X, EXC, STR) \
Expand All @@ -176,10 +176,10 @@ static inline std::string codeToString(cl_int code) {
#define __SYCL_CHECK_CODE_THROW_VIA_ERRC(X, ERRC) (void)(X)
#else
// SYCL 1.2.1 exceptions
#define __SYCL_CHECK_OCL_CODE(X) __SYCL_REPORT_OCL_ERR_TO_EXC_BASE(X)
#define __SYCL_CHECK_OCL_CODE(X) __SYCL_REPORT_PI_ERR_TO_EXC_BASE(X)
#define __SYCL_CHECK_OCL_CODE_THROW(X, EXC, STR) \
__SYCL_REPORT_OCL_ERR_TO_EXC_THROW(X, EXC, STR)
#define __SYCL_CHECK_OCL_CODE_NO_EXC(X) __SYCL_REPORT_OCL_ERR_TO_STREAM(X)
__SYCL_REPORT_PI_ERR_TO_EXC_THROW(X, EXC, STR)
#define __SYCL_CHECK_OCL_CODE_NO_EXC(X) __SYCL_REPORT_PI_ERR_TO_STREAM(X)
// SYCL 2020 exceptions
#define __SYCL_CHECK_CODE_THROW_VIA_ERRC(X, ERRC) \
__SYCL_REPORT_ERR_TO_EXC_THROW_VIA_ERRC(X, ERRC)
Expand Down
8 changes: 4 additions & 4 deletions sycl/include/CL/sycl/detail/host_profiling_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ namespace detail {

/// Profiling info for the host execution.
class __SYCL_EXPORT HostProfilingInfo {
cl_ulong StartTime = 0;
cl_ulong EndTime = 0;
uint64_t StartTime = 0;
uint64_t EndTime = 0;

public:
/// Returns event's start time.
///
/// \return event's start time in nanoseconds.
cl_ulong getStartTime() const { return StartTime; }
uint64_t getStartTime() const { return StartTime; }
/// Returns event's end time.
///
/// \return event's end time in nanoseconds.
cl_ulong getEndTime() const { return EndTime; }
uint64_t getEndTime() const { return EndTime; }

/// Measures event's start time.
void start();
Expand Down
1 change: 0 additions & 1 deletion sycl/include/CL/sycl/detail/memory_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#include <CL/sycl/access/access.hpp>
#include <CL/sycl/detail/cl.h>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/sycl_mem_obj_i.hpp>
#include <CL/sycl/id.hpp>
Expand Down
98 changes: 37 additions & 61 deletions sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,56 +83,12 @@ using pi_native_handle = uintptr_t;
// for PI <-> OpenCL ways. The PI <-> to other BE translation is almost
// always needed anyway.
//
// TODO: populate PI enums.
//
typedef enum {
PI_SUCCESS = 0,
PI_ERROR_INVALID_KERNEL_NAME = -46,
PI_ERROR_INVALID_OPERATION = -59,
PI_ERROR_INVALID_KERNEL = -48,
PI_ERROR_INVALID_QUEUE_PROPERTIES = -35,
PI_ERROR_INVALID_VALUE = -30,
PI_ERROR_INVALID_CONTEXT = -34,
PI_ERROR_INVALID_PLATFORM = -32,
PI_ERROR_INVALID_DEVICE = -33,
PI_ERROR_INVALID_BINARY = -42,
PI_ERROR_INVALID_QUEUE = -36,
PI_ERROR_OUT_OF_HOST_MEMORY = -6,
PI_ERROR_INVALID_PROGRAM = -44,
PI_ERROR_INVALID_PROGRAM_EXECUTABLE = -45,
PI_ERROR_INVALID_SAMPLER = -41,
PI_ERROR_INVALID_BUFFER_SIZE = -61,
PI_ERROR_INVALID_MEM_OBJECT = -38,
PI_ERROR_OUT_OF_RESOURCES = -5,
PI_ERROR_INVALID_EVENT = -58,
PI_ERROR_INVALID_EVENT_WAIT_LIST = -57,
PI_ERROR_MISALIGNED_SUB_BUFFER_OFFSET = -13,
PI_ERROR_BUILD_PROGRAM_FAILURE = -11,
PI_ERROR_INVALID_WORK_GROUP_SIZE = -54,
PI_ERROR_COMPILER_NOT_AVAILABLE = -3,
PI_ERROR_PROFILING_INFO_NOT_AVAILABLE = -7,
PI_ERROR_DEVICE_NOT_FOUND = -1,
PI_ERROR_INVALID_WORK_ITEM_SIZE = -55,
PI_ERROR_INVALID_WORK_DIMENSION = -53,
PI_ERROR_INVALID_KERNEL_ARGS = -52,
PI_ERROR_INVALID_IMAGE_SIZE = -40,
PI_ERROR_INVALID_ARG_VALUE = -50,
PI_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39,
PI_ERROR_IMAGE_FORMAT_NOT_SUPPORTED = -10,
PI_ERROR_MEM_OBJECT_ALLOCATION_FAILURE = -4,
PI_ERROR_LINK_PROGRAM_FAILURE = -17,
PI_ERROR_PLUGIN_SPECIFIC_ERROR =
-996, ///< PI_ERROR_PLUGIN_SPECIFIC_ERROR indicates
///< that an backend spcific error or
///< warning has been emitted by the plugin.
PI_ERROR_COMMAND_EXECUTION_FAILURE =
-997, ///< PI_ERROR_COMMAND_EXECUTION_FAILURE indicates an error occurred
///< during command enqueue or execution.
PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE =
-998, ///< PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE indicates a fallback
///< method determines the function exists but its address cannot be
///< found.
PI_ERROR_UNKNOWN = -999
#define _PI_ERRC(NAME, VAL) NAME = VAL,
#define _PI_ERRC_WITH_MSG(NAME, VAL, MSG) NAME = VAL,
#include <CL/sycl/detail/pi_error.def>
#undef _PI_ERRC
#undef _PI_ERRC_WITH_MSG
} _pi_result;

typedef enum {
Expand Down Expand Up @@ -180,8 +136,9 @@ typedef enum : pi_uint64 {
PI_DEVICE_TYPE_ALL = 0xFFFFFFFF, ///< All devices available in the PI plugin.
PI_DEVICE_TYPE_CPU = (1 << 1), ///< A PI device that is the host processor.
PI_DEVICE_TYPE_GPU = (1 << 2), ///< A PI device that is a GPU.
PI_DEVICE_TYPE_ACC = (1 << 3) ///< A PI device that is a
PI_DEVICE_TYPE_ACC = (1 << 3), ///< A PI device that is a
///< dedicated accelerator.
PI_DEVICE_TYPE_CUSTOM = (1 << 4) ///< A PI device that is a custom device.
} _pi_device_type;

typedef enum {
Expand Down Expand Up @@ -321,6 +278,7 @@ typedef enum {

typedef enum {
PI_CONTEXT_INFO_DEVICES = 0x1081,
PI_CONTEXT_INFO_PLATFORM = 0x1084,
PI_CONTEXT_INFO_NUM_DEVICES = 0x1083,
PI_CONTEXT_INFO_PROPERTIES = 0x1082,
PI_CONTEXT_INFO_REFERENCE_COUNT = 0x1080,
Expand Down Expand Up @@ -358,16 +316,6 @@ typedef enum {
PI_KERNEL_GROUP_INFO_NUM_REGS = 0x10112
} _pi_kernel_group_info;

typedef enum {
PI_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = (1 << 7),
PI_FP_ROUND_TO_NEAREST = (1 << 2),
PI_FP_ROUND_TO_ZERO = (1 << 3),
PI_FP_ROUND_TO_INF = (1 << 4),
PI_FP_INF_NAN = (1 << 1),
PI_FP_DENORM = (1 << 0),
PI_FP_FMA = (1 << 5)
} _pi_fp_capabilities;

typedef enum {
PI_IMAGE_INFO_FORMAT = 0x1110,
PI_IMAGE_INFO_ELEMENT_SIZE = 0x1111,
Expand Down Expand Up @@ -608,7 +556,6 @@ using pi_image_info = _pi_image_info;
using pi_kernel_info = _pi_kernel_info;
using pi_kernel_group_info = _pi_kernel_group_info;
using pi_kernel_sub_group_info = _pi_kernel_sub_group_info;
using pi_fp_capabilities = _pi_fp_capabilities;
using pi_event_info = _pi_event_info;
using pi_command_type = _pi_command_type;
using pi_mem_type = _pi_mem_type;
Expand All @@ -630,16 +577,45 @@ using pi_profiling_info = _pi_profiling_info;
using pi_device_partition_property = intptr_t;
static constexpr pi_device_partition_property PI_DEVICE_PARTITION_EQUALLY =
0x1086;
static constexpr pi_device_partition_property PI_DEVICE_PARTITION_BY_COUNTS =
0x1087;
static constexpr pi_device_partition_property
PI_DEVICE_PARTITION_BY_COUNTS_LIST_END = 0x0;
static constexpr pi_device_partition_property
PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN = 0x1088;

// For compatibility with OpenCL define this not as enum.
using pi_device_affinity_domain = pi_bitfield;
static constexpr pi_device_affinity_domain PI_DEVICE_AFFINITY_DOMAIN_NUMA =
(1 << 0);
static constexpr pi_device_affinity_domain PI_DEVICE_AFFINITY_DOMAIN_L4_CACHE =
(1 << 1);
static constexpr pi_device_affinity_domain PI_DEVICE_AFFINITY_DOMAIN_L3_CACHE =
(1 << 2);
static constexpr pi_device_affinity_domain PI_DEVICE_AFFINITY_DOMAIN_L2_CACHE =
(1 << 3);
static constexpr pi_device_affinity_domain PI_DEVICE_AFFINITY_DOMAIN_L1_CACHE =
(1 << 4);
static constexpr pi_device_affinity_domain
PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = (1 << 5);

// For compatibility with OpenCL define this not as enum.
using pi_device_fp_config = pi_bitfield;
static constexpr pi_device_fp_config PI_FP_DENORM = (1 << 0);
static constexpr pi_device_fp_config PI_FP_INF_NAN = (1 << 1);
static constexpr pi_device_fp_config PI_FP_ROUND_TO_NEAREST = (1 << 2);
static constexpr pi_device_fp_config PI_FP_ROUND_TO_ZERO = (1 << 3);
static constexpr pi_device_fp_config PI_FP_ROUND_TO_INF = (1 << 4);
static constexpr pi_device_fp_config PI_FP_FMA = (1 << 5);
static constexpr pi_device_fp_config PI_FP_SOFT_FLOAT = (1 << 6);
static constexpr pi_device_fp_config PI_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT =
(1 << 7);

// For compatibility with OpenCL define this not as enum.
using pi_device_exec_capabilities = pi_bitfield;
static constexpr pi_device_exec_capabilities PI_EXEC_KERNEL = (1 << 0);
static constexpr pi_device_exec_capabilities PI_EXEC_NATIVE_KERNEL = (1 << 1);

// Entry type, matches OpenMP for compatibility
struct _pi_offload_entry_struct {
void *addr;
Expand Down
Loading