-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Implement initial device_global registration (#5499)
These changes add required interface for the integration footer to register the `device_global` of a program as well as reading the extended information supplied by sycl-post-link through the "SYCL/device globals" property. The information is stored in a map managed by the program manager. Note that this is the first change to the runtime relating to `device_global` and as such the feature is not complete nor fully testable. It simply intents to add an interface for the integration footer as well as a consumer for the information sycl-post-link will be generating when future work is added. See [sycl/doc/DeviceGlobal.md](https://github.com/intel/llvm/blob/sycl/sycl/doc/DeviceGlobal.md).
- Loading branch information
1 parent
c536e76
commit 5931af5
Showing
8 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,21 @@ | ||
//==-------------------- device_global_map.hpp -----------------------------==// | ||
// | ||
// 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 | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
namespace device_global_map { | ||
|
||
void add(void *DeviceGlobalPtr, const char *UniqueId); | ||
|
||
} // namespace device_global_map | ||
} // namespace detail | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
This file contains 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 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 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 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,24 @@ | ||
//==-------------------- device_global_map.cpp -----------------------------==// | ||
// | ||
// 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 <detail/program_manager/program_manager.hpp> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
namespace device_global_map { | ||
|
||
void add(void *DeviceGlobalPtr, const char *UniqueId) { | ||
detail::ProgramManager::getInstance().addDeviceGlobalEntry(DeviceGlobalPtr, | ||
UniqueId); | ||
} | ||
|
||
} // namespace device_global_map | ||
} // namespace detail | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
This file contains 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,51 @@ | ||
//==----------------- device_global_map_entry.hpp --------------------------==// | ||
// | ||
// 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 | ||
|
||
#include <cstdint> | ||
#include <unordered_map> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
|
||
// Forward declaration | ||
class device_impl; | ||
|
||
struct DeviceGlobalMapEntry { | ||
// Pointer to the device_global on host. | ||
void *MDeviceGlobalPtr; | ||
// Size of the underlying type in the device_global. | ||
std::uint32_t MDeviceGlobalTSize; | ||
// True if the device_global has been decorated with device_image_scope | ||
bool MIsDeviceImageScopeDecorated; | ||
// Map between devices and corresponding USM allocations for the | ||
// device_global. This should always be empty if MIsDeviceImageScopeDecorated | ||
// is true. | ||
std::unordered_map<std::shared_ptr<device_impl>, void *> MDeviceToUSMPtrMap; | ||
|
||
// Constructor only initializes with the pointer to the device_global as the | ||
// additional information is loaded after. | ||
DeviceGlobalMapEntry(void *DeviceGlobalPtr) | ||
: MDeviceGlobalPtr(DeviceGlobalPtr), MDeviceGlobalTSize(0), | ||
MIsDeviceImageScopeDecorated(false) {} | ||
|
||
void initialize(std::uint32_t DeviceGlobalTSize, | ||
bool IsDeviceImageScopeDecorated) { | ||
assert(DeviceGlobalTSize != 0 && "Device global initialized with 0 size."); | ||
assert(MDeviceGlobalTSize == 0 && | ||
"Device global has already been initialized."); | ||
MDeviceGlobalTSize = DeviceGlobalTSize; | ||
MIsDeviceImageScopeDecorated = IsDeviceImageScopeDecorated; | ||
} | ||
}; | ||
|
||
} // namespace detail | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
This file contains 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 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