Skip to content

[SYCL] Move internal headers to source dir #1136

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 28 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function( add_common_options LIB_NAME)
endif()
endfunction(add_common_options)

set(SYCL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

# SYCL runtime library
add_subdirectory( source )

Expand Down
34 changes: 10 additions & 24 deletions sycl/include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <CL/sycl/detail/generic_type_traits.hpp>
#include <CL/sycl/detail/image_accessor_util.hpp>
#include <CL/sycl/detail/image_ocl_types.hpp>
#include <CL/sycl/detail/queue_impl.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see accessor_impl is still included here. Do you plan to leave it in public headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@romanovvlad romanovvlad Feb 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move at least AccessorImplHost to the private headers in a separate patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romanovvlad I'll do it as a separate patch.

#include <CL/sycl/exception.hpp>
#include <CL/sycl/handler.hpp>
#include <CL/sycl/id.hpp>
Expand Down Expand Up @@ -167,6 +166,8 @@ static T<NewDim> convertToArrayOfN(T<OldDim> OldObj) {
return NewObj;
}

device getDeviceFromHandler(handler &CommandGroupHandlerRef);

template <typename DataT, int Dimensions, access::mode AccessMode,
access::target AccessTarget, access::placeholder IsPlaceholder>
class accessor_common {
Expand Down Expand Up @@ -397,10 +398,7 @@ class image_accessor
MImageCount(ImageRef.get_count()),
MImgChannelOrder(detail::getSyclObjImpl(ImageRef)->getChannelOrder()),
MImgChannelType(detail::getSyclObjImpl(ImageRef)->getChannelType()) {
detail::EventImplPtr Event =
detail::Scheduler::getInstance().addHostAccessor(
AccessorBaseHost::impl.get());
Event->wait(Event);
addHostAccessorAndWait(AccessorBaseHost::impl.get());
}
#endif

Expand Down Expand Up @@ -429,7 +427,7 @@ class image_accessor
MImgChannelOrder(detail::getSyclObjImpl(ImageRef)->getChannelOrder()),
MImgChannelType(detail::getSyclObjImpl(ImageRef)->getChannelType()) {
checkDeviceFeatureSupported<info::device::image_support>(
CommandGroupHandlerRef.MQueue->get_device());
getDeviceFromHandler(CommandGroupHandlerRef));
}
#endif

Expand Down Expand Up @@ -770,12 +768,8 @@ class accessor :
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()), AccessMode,
detail::getSyclObjImpl(BufferRef).get(), AdjustedDim, sizeof(DataT),
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
if (!IsPlaceH) {
detail::EventImplPtr Event =
detail::Scheduler::getInstance().addHostAccessor(
AccessorBaseHost::impl.get());
Event->wait(Event);
}
if (!IsPlaceH)
addHostAccessorAndWait(AccessorBaseHost::impl.get());
#endif
}

Expand Down Expand Up @@ -814,12 +808,8 @@ class accessor :
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()), AccessMode,
detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT),
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
if (!IsPlaceH) {
detail::EventImplPtr Event =
detail::Scheduler::getInstance().addHostAccessor(
AccessorBaseHost::impl.get());
Event->wait(Event);
}
if (!IsPlaceH)
addHostAccessorAndWait(AccessorBaseHost::impl.get());
}
#endif

Expand Down Expand Up @@ -858,12 +848,8 @@ class accessor :
AccessMode, detail::getSyclObjImpl(BufferRef).get(),
Dimensions, sizeof(DataT), BufferRef.OffsetInBytes,
BufferRef.IsSubBuffer) {
if (!IsPlaceH) {
detail::EventImplPtr Event =
detail::Scheduler::getInstance().addHostAccessor(
AccessorBaseHost::impl.get());
Event->wait(Event);
}
if (!IsPlaceH)
addHostAccessorAndWait(AccessorBaseHost::impl.get());
}
#endif

Expand Down
7 changes: 2 additions & 5 deletions sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,8 @@ class buffer {
event AvailableEvent = {})
: Range{0} {

size_t BufSize = 0;
const detail::plugin &Plugin = detail::getSyclObjImpl(SyclContext)->getPlugin();
Plugin.call<detail::PiApiKind::piMemGetInfo>(
detail::pi::cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE,
sizeof(size_t), &BufSize, nullptr);
size_t BufSize = detail::SYCLMemObjT::getBufSizeForContext(
detail::getSyclObjImpl(SyclContext), MemObject);

Range[0] = BufSize / sizeof(T);
impl = std::make_shared<detail::buffer_impl>(
Expand Down
2 changes: 2 additions & 0 deletions sycl/include/CL/sycl/detail/accessor_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class LocalAccessorBaseHost {

using Requirement = AccessorImplHost;

void addHostAccessorAndWait(Requirement *Req);

} // namespace detail
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
9 changes: 0 additions & 9 deletions sycl/include/CL/sycl/detail/image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ template <int Dimensions> class image_impl final : public SYCLMemObjT {
~image_impl() { BaseT::updateHostMemory(); }

private:
template <typename T>
void getImageInfo(const ContextImplPtr Context, RT::PiMemImageInfo Info,
T &Dest) {
const detail::plugin &Plugin = Context->getPlugin();
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
Plugin.call<PiApiKind::piMemImageGetInfo>(Mem, Info, sizeof(T), &Dest,
nullptr);
}

vector_class<device> getDevices(const ContextImplPtr Context);

template <info::device Param>
Expand Down
11 changes: 7 additions & 4 deletions sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include <CL/sycl/detail/pi.hpp>
#include <memory>
#include <CL/sycl/stl.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand All @@ -20,8 +20,8 @@ class event_impl;
class context_impl;
struct MemObjRecord;

using EventImplPtr = std::shared_ptr<detail::event_impl>;
using ContextImplPtr = std::shared_ptr<detail::context_impl>;
using EventImplPtr = shared_ptr_class<detail::event_impl>;
using ContextImplPtr = shared_ptr_class<detail::context_impl>;

// The class serves as an interface in the scheduler for all SYCL memory
// objects.
Expand Down Expand Up @@ -64,7 +64,10 @@ class SYCLMemObjI {
protected:
// Pointer to the record that contains the memory commands. This is managed
// by the scheduler.
std::unique_ptr<MemObjRecord> MRecord;
// fixme replace with unique_ptr_class once it is implemented. Standard
// unique_ptr requires knowlege of sizeof(MemObjRecord) at compile time
// which is unavailable.
shared_ptr_class<MemObjRecord> MRecord;
friend class Scheduler;
};

Expand Down
13 changes: 6 additions & 7 deletions sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#pragma once

#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/context_impl.hpp>
#include <CL/sycl/detail/sycl_mem_obj_allocator.hpp>
#include <CL/sycl/detail/plugin.hpp>
#include <CL/sycl/detail/sycl_mem_obj_i.hpp>
#include <CL/sycl/detail/type_traits.hpp>
#include <CL/sycl/event.hpp>
Expand All @@ -26,7 +24,9 @@ namespace sycl {
namespace detail {

// Forward declarations
class context_impl;
class event_impl;
class plugin;

using ContextImplPtr = shared_ptr_class<context_impl>;
using EventImplPtr = shared_ptr_class<event_impl>;
Expand Down Expand Up @@ -83,11 +83,8 @@ class SYCLMemObjT : public SYCLMemObjI {

virtual ~SYCLMemObjT() = default;

const plugin &getPlugin() const {
assert((MInteropContext != nullptr) &&
"Trying to get Plugin from SYCLMemObjT with nullptr ContextImpl.");
return (MInteropContext->getPlugin());
}
const plugin &getPlugin() const;

size_t getSize() const override { return MSizeInBytes; }
size_t get_count() const {
size_t AllocatorValueSize = MAllocator->getValueSize();
Expand Down Expand Up @@ -259,6 +256,8 @@ class SYCLMemObjT : public SYCLMemObjI {
MAllocator->setAlignment(RequiredAlign);
}

static size_t getBufSizeForContext(ContextImplPtr Context, cl_mem MemObject);

protected:
// Allocator used for allocation memory on host.
unique_ptr_class<SYCLMemObjAllocator> MAllocator;
Expand Down
3 changes: 3 additions & 0 deletions sycl/include/CL/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace sycl {

// Forward declaration

class handler;
template <typename T, int Dimensions, typename AllocatorT> class buffer;
namespace detail {

Expand Down Expand Up @@ -104,6 +105,7 @@ template <typename Type> struct get_kernel_name_t<detail::auto_name, Type> {
using name = Type;
};

device getDeviceFromHandler(handler &);
} // namespace detail

/// 4.8.3 Command group handler class
Expand Down Expand Up @@ -1278,6 +1280,7 @@ class handler {
template <typename DataT, int Dims, access::mode AccMode,
access::target AccTarget, access::placeholder isPlaceholder>
friend class accessor;
friend device detail::getDeviceFromHandler(handler &);

template <typename DataT, int Dimensions, access::mode AccessMode,
access::target AccessTarget, access::placeholder IsPlaceholder>
Expand Down
1 change: 0 additions & 1 deletion sycl/include/CL/sycl/intel/function_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#pragma once

#include <CL/sycl/detail/plugin.hpp>
#include <CL/sycl/device.hpp>
#include <CL/sycl/program.hpp>
#include <CL/sycl/stl.hpp>
Expand Down
1 change: 0 additions & 1 deletion sycl/include/CL/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

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

// 4.6.2 Platform class
Expand Down
11 changes: 4 additions & 7 deletions sycl/include/CL/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#pragma once

#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/device.hpp>
#include <CL/sycl/device_selector.hpp>
#include <CL/sycl/event.hpp>
#include <CL/sycl/exception_list.hpp>
#include <CL/sycl/handler.hpp>
#include <CL/sycl/info/info_desc.hpp>
#include <CL/sycl/property_list.hpp>
#include <CL/sycl/stl.hpp>
Expand Down Expand Up @@ -107,10 +109,7 @@ class queue {
/// @param SyclDevice is an instance of SYCL device.
/// @param PropList is a list of properties for queue construction.
queue(const context &SyclContext, const device &SyclDevice,
const property_list &PropList = {})
: queue(SyclContext, SyclDevice,
detail::getSyclObjImpl(SyclContext)->get_async_handler(),
PropList) {};
const property_list &PropList = {});

/// Constructs a SYCL queue associated with the given context, device,
/// asynchronous exception handler and optional properties list.
Expand Down Expand Up @@ -447,9 +446,7 @@ class queue {
/// Returns whether the queue is in order or OoO
///
/// Equivalent to has_property<property::queue::in_order>()
bool is_in_order() const {
return impl->has_property<property::queue::in_order>();
}
bool is_in_order() const;

private:
shared_ptr_class<detail::queue_impl> impl;
Expand Down
1 change: 1 addition & 0 deletions sycl/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ set(SYCL_SOURCES
"detail/usm/usm_dispatch.cpp"
"detail/usm/usm_impl.cpp"
"detail/util.cpp"
"accessor.cpp"
"context.cpp"
"device.cpp"
"device_selector.cpp"
Expand Down
20 changes: 20 additions & 0 deletions sycl/source/accessor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//==------------ accessor.cpp - SYCL standard source 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
//
//===----------------------------------------------------------------------===//

#include <CL/sycl/accessor.hpp>
#include <detail/queue_impl.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {
device getDeviceFromHandler(handler &CommandGroupHandlerRef) {
return CommandGroupHandlerRef.MQueue->get_device();
}
} // namespace detail
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
3 changes: 2 additions & 1 deletion sycl/source/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

#include <CL/sycl/context.hpp>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/context_impl.hpp>
#include <CL/sycl/device.hpp>
#include <CL/sycl/device_selector.hpp>
#include <CL/sycl/exception.hpp>
#include <CL/sycl/exception_list.hpp>
#include <CL/sycl/platform.hpp>
#include <CL/sycl/stl.hpp>
#include <detail/context_impl.hpp>

#include <algorithm>
#include <memory>
#include <utility>
Expand Down
9 changes: 8 additions & 1 deletion sycl/source/detail/accessor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//===----------------------------------------------------------------------===//

#include <CL/sycl/detail/accessor_impl.hpp>
#include <CL/sycl/detail/scheduler/scheduler.hpp>
#include <detail/event_impl.hpp>
#include <detail/scheduler/scheduler.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand All @@ -17,6 +18,12 @@ AccessorImplHost::~AccessorImplHost() {
if (MBlockedCmd)
detail::Scheduler::getInstance().releaseHostAccessor(this);
}

void addHostAccessorAndWait(Requirement *Req) {
detail::EventImplPtr Event =
detail::Scheduler::getInstance().addHostAccessor(Req);
Event->wait(Event);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/buffer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//

#include <CL/sycl/detail/buffer_impl.hpp>
#include <CL/sycl/detail/context_impl.hpp>
#include <CL/sycl/detail/memory_manager.hpp>
#include <CL/sycl/detail/scheduler/scheduler.hpp>
#include <detail/context_impl.hpp>
#include <detail/scheduler/scheduler.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#pragma once

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

#include <cstdlib>

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

#include <CL/sycl/detail/clusm.hpp>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/context_impl.hpp>
#include <CL/sycl/detail/context_info.hpp>
#include <CL/sycl/device.hpp>
#include <CL/sycl/exception.hpp>
#include <CL/sycl/exception_list.hpp>
#include <CL/sycl/info/info_desc.hpp>
#include <CL/sycl/platform.hpp>
#include <CL/sycl/stl.hpp>
#include <detail/context_impl.hpp>
#include <detail/context_info.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand Down
Loading