Skip to content

[SYCL] Only export public API #1456

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
merged 6 commits into from
Apr 7, 2020
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: 0 additions & 1 deletion sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ project(sycl-solution)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
option(SYCL_ENABLE_WERROR "Treat all warnings as errors in SYCL project" OFF)

# enable all warnings by default
Expand Down
10 changes: 6 additions & 4 deletions sycl/include/CL/__spirv/spirv_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once
#include <CL/__spirv/spirv_types.hpp>
#include <CL/sycl/detail/defines.hpp>
#include <CL/sycl/detail/export.hpp>
#include <cstddef>
#include <cstdint>
#include <type_traits>
Expand Down Expand Up @@ -256,16 +257,17 @@ OpGroupAsyncCopyLocalToGlobal(__spv::Scope::Flag Execution, dataT *Dest,
return nullptr;
}

extern void __spirv_ocl_prefetch(const char *Ptr, size_t NumBytes) noexcept;
extern __SYCL_EXPORT void __spirv_ocl_prefetch(const char *Ptr,
size_t NumBytes) noexcept;

__SYCL_CONVERGENT__ extern SYCL_EXTERNAL void
__SYCL_CONVERGENT__ extern SYCL_EXTERNAL __SYCL_EXPORT void
__spirv_ControlBarrier(__spv::Scope Execution, __spv::Scope Memory,
uint32_t Semantics) noexcept;

__SYCL_CONVERGENT__ extern SYCL_EXTERNAL void
__SYCL_CONVERGENT__ extern SYCL_EXTERNAL __SYCL_EXPORT void
__spirv_MemoryBarrier(__spv::Scope Memory, uint32_t Semantics) noexcept;

__SYCL_CONVERGENT__ extern SYCL_EXTERNAL void
__SYCL_CONVERGENT__ extern SYCL_EXTERNAL __SYCL_EXPORT void
__spirv_GroupWaitEvents(__spv::Scope Execution, uint32_t NumEvents,
__ocl_event_t *WaitEvents) noexcept;

Expand Down
4 changes: 3 additions & 1 deletion sycl/include/CL/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

#pragma once
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/exception_list.hpp>
#include <CL/sycl/info/info_desc.hpp>
#include <CL/sycl/stl.hpp>

#include <type_traits>
// 4.6.2 Context class

Expand All @@ -23,7 +25,7 @@ namespace detail {
class context_impl;
}

class context {
class __SYCL_EXPORT context {
public:
/// Constructs a SYCL context instance using an instance of default_selector.
///
Expand Down
10 changes: 5 additions & 5 deletions sycl/include/CL/sycl/detail/accessor_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <CL/sycl/access/access.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/sycl_mem_obj_i.hpp>
#include <CL/sycl/id.hpp>
#include <CL/sycl/range.hpp>
Expand Down Expand Up @@ -37,8 +38,7 @@ template <int Dims> class AccessorImplDevice {
range<Dims> MemRange;

bool operator==(const AccessorImplDevice &Rhs) const {
return (Offset == Rhs.Offset &&
AccessRange == Rhs.AccessRange &&
return (Offset == Rhs.Offset && AccessRange == Rhs.AccessRange &&
MemRange == Rhs.MemRange);
}
};
Expand All @@ -59,7 +59,7 @@ template <int Dims> class LocalAccessorBaseDevice {
}
};

class AccessorImplHost {
class __SYCL_EXPORT AccessorImplHost {
public:
AccessorImplHost(id<3> Offset, range<3> AccessRange, range<3> MemoryRange,
access::mode AccessMode, detail::SYCLMemObjI *SYCLMemObject,
Expand Down Expand Up @@ -129,7 +129,7 @@ class AccessorBaseHost {
AccessorImplPtr impl;
};

class LocalAccessorImplHost {
class __SYCL_EXPORT LocalAccessorImplHost {
public:
LocalAccessorImplHost(sycl::range<3> Size, int Dims, int ElemSize)
: MSize(Size), MDims(Dims), MElemSize(ElemSize),
Expand Down Expand Up @@ -185,7 +185,7 @@ class LocalAccessorBaseHost {

using Requirement = AccessorImplHost;

void addHostAccessorAndWait(Requirement *Req);
void __SYCL_EXPORT addHostAccessorAndWait(Requirement *Req);

} // namespace detail
} // namespace sycl
Expand Down
5 changes: 3 additions & 2 deletions sycl/include/CL/sycl/detail/buffer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <CL/sycl/access/access.hpp>
#include <CL/sycl/context.hpp>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/helpers.hpp>
#include <CL/sycl/detail/sycl_mem_obj_t.hpp>
#include <CL/sycl/handler.hpp>
Expand All @@ -38,7 +39,7 @@ using buffer_allocator = detail::sycl_memory_object_allocator;

namespace detail {

class buffer_impl final : public SYCLMemObjT {
class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
using BaseT = SYCLMemObjT;
using typename BaseT::MemObjType;

Expand Down Expand Up @@ -104,7 +105,7 @@ class buffer_impl final : public SYCLMemObjT {
std::move(Allocator)) {}

void *allocateMem(ContextImplPtr Context, bool InitFromUserData,
void *HostPtr, RT::PiEvent &OutEventToWait) override;
void *HostPtr, RT::PiEvent &OutEventToWait) override;

MemObjType getType() const override { return MemObjType::BUFFER; }

Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/cg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <CL/sycl/detail/accessor_impl.hpp>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/helpers.hpp>
#include <CL/sycl/detail/host_profiling_info.hpp>
#include <CL/sycl/detail/kernel_desc.hpp>
Expand Down Expand Up @@ -55,7 +56,7 @@ class interop_handler {
private:
cl_command_queue MQueue;
std::vector<ReqToMem> MMemObjs;
cl_mem getMemImpl(detail::Requirement* Req) const;
__SYCL_EXPORT cl_mem getMemImpl(detail::Requirement *Req) const;
};

namespace detail {
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <CL/sycl/detail/defines.hpp>
#include <CL/sycl/detail/export.hpp>

// Suppress a compiler warning about undefined CL_TARGET_OPENCL_VERSION
// Khronos ICD supports only latest OpenCL version
Expand Down Expand Up @@ -84,7 +85,7 @@ __SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

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

static inline std::string codeToString(cl_int code) {
return std::string(std::to_string(code) + " (" + stringifyErrorCode(code) +
Expand Down
5 changes: 3 additions & 2 deletions sycl/include/CL/sycl/detail/common_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
//===----------------------------------------------------------------------===//

#pragma once
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/stl.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

vector_class<string_class> split_string(const string_class &str,
char delimeter);
vector_class<string_class> __SYCL_EXPORT split_string(const string_class &str,
char delimeter);

} // namespace detail
} // namespace sycl
Expand Down
8 changes: 0 additions & 8 deletions sycl/include/CL/sycl/detail/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,3 @@
#ifndef SYCL_EXTERNAL
#define SYCL_EXTERNAL
#endif

#if __cplusplus >= 201402
#define __SYCL_DEPRECATED__(message) [[deprecated(message)]]
#elif !defined _MSC_VER
#define __SYCL_DEPRECATED__(message) __attribute__((deprecated(message)))
#else
#define __SYCL_DEPRECATED__(message)
#endif
38 changes: 38 additions & 0 deletions sycl/include/CL/sycl/detail/export.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//==---------------- export.hpp - SYCL standard header file ----------------==//
//
// 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
//
//===----------------------------------------------------------------------===//

#pragma once

#ifndef SYCL_DEVICE_ONLY
#ifndef __SYCL_EXPORT
#ifdef _WIN32

// MSVC discourages export of classes, that use STL class in API. This
// results in a warning, treated as compile error. Silence C4251 to workaround.
#pragma warning(disable : 4251)
#pragma warning(disable : 4275)

#define DLL_LOCAL

#if __SYCL_BUILD_SYCL_DLL
#define __SYCL_EXPORT __declspec(dllexport)
#define __SYCL_EXPORT_DEPRECATED(x) __declspec(dllexport, deprecated(x))
#else
#define __SYCL_EXPORT __declspec(dllimport)
#define __SYCL_EXPORT_DEPRECATED(x) __declspec(dllimport, deprecated(x))
#endif
#else

#define DLL_LOCAL __attribute__((visibility("hidden")))

#define __SYCL_EXPORT __attribute__((visibility("default")))
#define __SYCL_EXPORT_DEPRECATED(x) \
__attribute__((visibility("default"), deprecated(x)))
#endif
#endif
#endif
3 changes: 1 addition & 2 deletions sycl/include/CL/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,7 @@ class is_same_vector_size_impl<FirstSize, T, Args...> {

public:
static constexpr bool value =
IsSizeEqual ? is_same_vector_size_impl<FirstSize, Args...>::value
: false;
IsSizeEqual ? is_same_vector_size_impl<FirstSize, Args...>::value : false;
};

template <int FirstSize>
Expand Down
5 changes: 3 additions & 2 deletions sycl/include/CL/sycl/detail/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <CL/__spirv/spirv_vars.hpp>
#include <CL/sycl/access/access.hpp>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/pi.hpp>
#include <CL/sycl/detail/type_traits.hpp>

Expand Down Expand Up @@ -44,11 +45,11 @@ inline void memcpy(void *Dst, const void *Src, size_t Size) {
class context_impl;
// The function returns list of events that can be passed to OpenCL API as
// dependency list and waits for others.
std::vector<RT::PiEvent>
__SYCL_EXPORT std::vector<RT::PiEvent>
getOrWaitEvents(std::vector<cl::sycl::event> DepEvents,
std::shared_ptr<cl::sycl::detail::context_impl> Context);

void waitEvents(std::vector<cl::sycl::event> DepEvents);
__SYCL_EXPORT void waitEvents(std::vector<cl::sycl::event> DepEvents);

class Builder {
public:
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/host_profiling_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
#pragma once

#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

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

Expand Down
19 changes: 12 additions & 7 deletions sycl/include/CL/sycl/detail/image_accessor_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#ifndef __SYCL_DEVICE_ONLY__
#include <CL/sycl/builtins.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/generic_type_traits.hpp>
#include <CL/sycl/image.hpp>
#include <CL/sycl/sampler.hpp>
Expand Down Expand Up @@ -99,21 +100,25 @@ getImageOffset(const vec<T, 4> &Coords, const id<3> ImgPitch,

// Process cl_float4 Coordinates and return the appropriate Pixel Coordinates to
// read from based on Addressing Mode for Nearest filter mode.
cl_int4 getPixelCoordNearestFiltMode(cl_float4, const addressing_mode,
const range<3>);
__SYCL_EXPORT cl_int4 getPixelCoordNearestFiltMode(cl_float4,
const addressing_mode,
const range<3>);

// Process cl_float4 Coordinates and return the appropriate Pixel Coordinates to
// read from based on Addressing Mode for Linear filter mode.
cl_int8 getPixelCoordLinearFiltMode(cl_float4, const addressing_mode,
const range<3>, cl_float4 &);
__SYCL_EXPORT cl_int8 getPixelCoordLinearFiltMode(cl_float4,
const addressing_mode,
const range<3>, cl_float4 &);

// Check if PixelCoord are out of range for Sampler with clamp adressing mode.
bool isOutOfRange(const cl_int4 PixelCoord, const addressing_mode SmplAddrMode,
const range<3> ImgRange);
__SYCL_EXPORT bool isOutOfRange(const cl_int4 PixelCoord,
const addressing_mode SmplAddrMode,
const range<3> ImgRange);

// Get Border Color for the image_channel_order, the border color values are
// only used when the sampler has clamp addressing mode.
cl_float4 getBorderColor(const image_channel_order ImgChannelOrder);
__SYCL_EXPORT cl_float4
getBorderColor(const image_channel_order ImgChannelOrder);

// Reads data from a pixel at Ptr location, based on the number of Channels in
// Order and returns the data.
Expand Down
21 changes: 14 additions & 7 deletions sycl/include/CL/sycl/detail/image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <CL/sycl/detail/aligned_allocator.hpp>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/generic_type_traits.hpp>
#include <CL/sycl/detail/sycl_mem_obj_t.hpp>
#include <CL/sycl/device.hpp>
Expand Down Expand Up @@ -37,18 +38,23 @@ namespace detail {
using image_allocator = aligned_allocator<byte>;

// utility function: Returns the Number of Channels for a given Order.
uint8_t getImageNumberChannels(image_channel_order Order);
__SYCL_EXPORT uint8_t getImageNumberChannels(image_channel_order Order);

// utility function: Returns the number of bytes per image element
uint8_t getImageElementSize(uint8_t NumChannels, image_channel_type Type);
__SYCL_EXPORT uint8_t getImageElementSize(uint8_t NumChannels,
image_channel_type Type);

RT::PiMemImageChannelOrder convertChannelOrder(image_channel_order Order);
__SYCL_EXPORT RT::PiMemImageChannelOrder
convertChannelOrder(image_channel_order Order);

image_channel_order convertChannelOrder(RT::PiMemImageChannelOrder Order);
__SYCL_EXPORT image_channel_order
convertChannelOrder(RT::PiMemImageChannelOrder Order);

RT::PiMemImageChannelType convertChannelType(image_channel_type Type);
__SYCL_EXPORT RT::PiMemImageChannelType
convertChannelType(image_channel_type Type);

image_channel_type convertChannelType(RT::PiMemImageChannelType Type);
__SYCL_EXPORT image_channel_type
convertChannelType(RT::PiMemImageChannelType Type);

// validImageDataT: cl_int4, cl_uint4, cl_float4, cl_half4
template <typename T>
Expand All @@ -59,7 +65,8 @@ template <typename DataT>
using EnableIfImgAccDataT =
typename std::enable_if<is_validImageDataT<DataT>::value, DataT>::type;

template <int Dimensions> class image_impl final : public SYCLMemObjT {
template <int Dimensions>
class __SYCL_EXPORT image_impl final : public SYCLMemObjT {
using BaseT = SYCLMemObjT;
using typename BaseT::MemObjType;

Expand Down
5 changes: 4 additions & 1 deletion sycl/include/CL/sycl/detail/kernel_desc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
#pragma once

#include <CL/sycl/access/access.hpp>
#include <CL/sycl/detail/os_util.hpp> // for DLL_LOCAL used in int. header
#include <CL/sycl/detail/defines.hpp>
#include <CL/sycl/detail/export.hpp> // for DLL_LOCAL used in int. header

#include <cstddef>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand Down
Loading