Skip to content

Commit

Permalink
[UR] Remove UMF sources and use standalone UMF repo instead
Browse files Browse the repository at this point in the history
UMF has become a separate project with its own repository.
It is currently under active development and is intended to
be used by various oneAPI components, not just UR. All
further enhancements and fixes will only go into the UMF
repository - we do not plan to merge such changes here in
the UR repository and into the UMF repository separately.
  • Loading branch information
igchor authored and kbenzie committed Feb 13, 2024
1 parent f15234d commit e3eff58
Show file tree
Hide file tree
Showing 58 changed files with 148 additions and 5,694 deletions.
1 change: 0 additions & 1 deletion source/adapters/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ endif()
target_link_libraries(${TARGET_NAME} PRIVATE
${PROJECT_NAME}::headers
${PROJECT_NAME}::common
${PROJECT_NAME}::unified_malloc_framework
Threads::Threads
cudadrv
)
Expand Down
18 changes: 9 additions & 9 deletions source/adapters/cuda/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,28 +401,28 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
.second;

HostMemPool =
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Host])
umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Host])
.second;

auto Device = Context->DeviceID;
MemProvider =
umf::memoryProviderMakeUnique<USMDeviceMemoryProvider>(Context, Device)
.second;
DeviceMemPool =
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Device])
umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Device])
.second;

MemProvider =
umf::memoryProviderMakeUnique<USMSharedMemoryProvider>(Context, Device)
.second;
SharedMemPool =
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Shared])
umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Shared])
.second;
Context->addPool(this);
}
Expand Down
1 change: 0 additions & 1 deletion source/adapters/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ if("${UR_HIP_PLATFORM}" STREQUAL "AMD")
target_link_libraries(${TARGET_NAME} PRIVATE
${PROJECT_NAME}::headers
${PROJECT_NAME}::common
${PROJECT_NAME}::unified_malloc_framework
rocmdrv
)

Expand Down
26 changes: 13 additions & 13 deletions source/adapters/hip/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,29 +345,29 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
.second;

HostMemPool =
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Host])
umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Host])
.second;

for (const auto &Device : Context->getDevices()) {
MemProvider =
umf::memoryProviderMakeUnique<USMDeviceMemoryProvider>(Context, Device)
.second;
DeviceMemPool =
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Device])
.second;
DeviceMemPool = umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs
.Configs[usm::DisjointPoolMemType::Device])
.second;

MemProvider =
umf::memoryProviderMakeUnique<USMSharedMemoryProvider>(Context, Device)
.second;
SharedMemPool =
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Shared])
.second;
SharedMemPool = umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs
.Configs[usm::DisjointPoolMemType::Shared])
.second;
Context->addPool(this);
}
}
Expand Down
1 change: 0 additions & 1 deletion source/adapters/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ endif()
target_link_libraries(${TARGET_NAME} PRIVATE
${PROJECT_NAME}::headers
${PROJECT_NAME}::common
${PROJECT_NAME}::unified_malloc_framework
LevelZeroLoader
LevelZeroLoader-Headers
)
Expand Down
41 changes: 19 additions & 22 deletions source/adapters/level_zero/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,21 @@ ur_result_t ur_context_handle_t_::initialize() {
.second;
DeviceMemPools.emplace(
std::piecewise_construct, std::make_tuple(Device->ZeDevice),
std::make_tuple(umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
DisjointPoolConfigInstance
.Configs[usm::DisjointPoolMemType::Device])
std::make_tuple(umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&DisjointPoolConfigInstance
.Configs[usm::DisjointPoolMemType::Device])
.second));

MemProvider = umf::memoryProviderMakeUnique<L0SharedMemoryProvider>(
reinterpret_cast<ur_context_handle_t>(this), Device)
.second;
SharedMemPools.emplace(
std::piecewise_construct, std::make_tuple(Device->ZeDevice),
std::make_tuple(umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
DisjointPoolConfigInstance
.Configs[usm::DisjointPoolMemType::Shared])
std::make_tuple(umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&DisjointPoolConfigInstance
.Configs[usm::DisjointPoolMemType::Shared])
.second));

MemProvider = umf::memoryProviderMakeUnique<L0SharedReadOnlyMemoryProvider>(
Expand All @@ -212,10 +212,10 @@ ur_result_t ur_context_handle_t_::initialize() {
SharedReadOnlyMemPools.emplace(
std::piecewise_construct, std::make_tuple(Device->ZeDevice),
std::make_tuple(
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
DisjointPoolConfigInstance
.Configs[usm::DisjointPoolMemType::SharedReadOnly])
umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&DisjointPoolConfigInstance
.Configs[usm::DisjointPoolMemType::SharedReadOnly])
.second));

MemProvider = umf::memoryProviderMakeUnique<L0DeviceMemoryProvider>(
Expand All @@ -224,26 +224,23 @@ ur_result_t ur_context_handle_t_::initialize() {
DeviceMemProxyPools.emplace(
std::piecewise_construct, std::make_tuple(Device->ZeDevice),
std::make_tuple(
umf::poolMakeUnique<USMProxyPool, 1>({std::move(MemProvider)})
.second));
umf::poolMakeUnique<USMProxyPool>(std::move(MemProvider)).second));

MemProvider = umf::memoryProviderMakeUnique<L0SharedMemoryProvider>(
reinterpret_cast<ur_context_handle_t>(this), Device)
.second;
SharedMemProxyPools.emplace(
std::piecewise_construct, std::make_tuple(Device->ZeDevice),
std::make_tuple(
umf::poolMakeUnique<USMProxyPool, 1>({std::move(MemProvider)})
.second));
umf::poolMakeUnique<USMProxyPool>(std::move(MemProvider)).second));

MemProvider = umf::memoryProviderMakeUnique<L0SharedReadOnlyMemoryProvider>(
reinterpret_cast<ur_context_handle_t>(this), Device)
.second;
SharedReadOnlyMemProxyPools.emplace(
std::piecewise_construct, std::make_tuple(Device->ZeDevice),
std::make_tuple(
umf::poolMakeUnique<USMProxyPool, 1>({std::move(MemProvider)})
.second));
umf::poolMakeUnique<USMProxyPool>(std::move(MemProvider)).second));
};

// Recursive helper to call createUSMAllocators for all sub-devices
Expand All @@ -268,16 +265,16 @@ ur_result_t ur_context_handle_t_::initialize() {
reinterpret_cast<ur_context_handle_t>(this), nullptr)
.second;
HostMemPool =
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
DisjointPoolConfigInstance.Configs[usm::DisjointPoolMemType::Host])
umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&DisjointPoolConfigInstance.Configs[usm::DisjointPoolMemType::Host])
.second;

MemProvider = umf::memoryProviderMakeUnique<L0HostMemoryProvider>(
reinterpret_cast<ur_context_handle_t>(this), nullptr)
.second;
HostMemProxyPool =
umf::poolMakeUnique<USMProxyPool, 1>({std::move(MemProvider)}).second;
umf::poolMakeUnique<USMProxyPool>(std::move(MemProvider)).second;

// We may allocate memory to this root device so create allocators.
if (SingleRootDevice &&
Expand Down
30 changes: 15 additions & 15 deletions source/adapters/level_zero/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,9 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
.second;

HostMemPool =
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Host])
umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs.Configs[usm::DisjointPoolMemType::Host])
.second;

for (auto device : Context->Devices) {
Expand All @@ -845,21 +845,21 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
.second;
DeviceMemPools.emplace(
std::piecewise_construct, std::make_tuple(device),
std::make_tuple(umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs
.Configs[usm::DisjointPoolMemType::Device])
std::make_tuple(umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs
.Configs[usm::DisjointPoolMemType::Device])
.second));

MemProvider =
umf::memoryProviderMakeUnique<L0SharedMemoryProvider>(Context, device)
.second;
SharedMemPools.emplace(
std::piecewise_construct, std::make_tuple(device),
std::make_tuple(umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs
.Configs[usm::DisjointPoolMemType::Shared])
std::make_tuple(umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs
.Configs[usm::DisjointPoolMemType::Shared])
.second));

MemProvider = umf::memoryProviderMakeUnique<L0SharedReadOnlyMemoryProvider>(
Expand All @@ -868,10 +868,10 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
SharedReadOnlyMemPools.emplace(
std::piecewise_construct, std::make_tuple(device),
std::make_tuple(
umf::poolMakeUnique<usm::DisjointPool, 1>(
{std::move(MemProvider)},
this->DisjointPoolConfigs
.Configs[usm::DisjointPoolMemType::SharedReadOnly])
umf::poolMakeUniqueFromOps(
&UMF_DISJOINT_POOL_OPS, std::move(MemProvider),
&this->DisjointPoolConfigs
.Configs[usm::DisjointPoolMemType::SharedReadOnly])
.second));
}
}
Expand Down
7 changes: 2 additions & 5 deletions source/adapters/level_zero/usm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,8 @@ class L0HostMemoryProvider final : public L0MemoryProvider {
// capabilities.
class USMProxyPool {
public:
umf_result_t initialize(umf_memory_provider_handle_t *Providers,
size_t NumProviders) noexcept {
std::ignore = NumProviders;

this->hProvider = Providers[0];
umf_result_t initialize(umf_memory_provider_handle_t Provider) noexcept {
this->hProvider = Provider;
return UMF_RESULT_SUCCESS;
}
void *malloc(size_t Size) noexcept { return aligned_malloc(Size, 0); }
Expand Down
1 change: 0 additions & 1 deletion source/adapters/opencl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ target_include_directories(${TARGET_NAME} PRIVATE
target_link_libraries(${TARGET_NAME} PRIVATE
${PROJECT_NAME}::headers
${PROJECT_NAME}::common
${PROJECT_NAME}::unified_malloc_framework
Threads::Threads
${OpenCLICDLoaderLibrary}
)
30 changes: 25 additions & 5 deletions source/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

add_subdirectory(unified_malloc_framework)
add_subdirectory(umf_pools)

add_ur_library(ur_common STATIC
umf_helpers.hpp
umf_pools/disjoint_pool_config_parser.cpp
ur_pool_manager.hpp
ur_util.cpp
ur_util.hpp
Expand All @@ -21,9 +19,31 @@ target_include_directories(ur_common PUBLIC
${CMAKE_SOURCE_DIR}/include
)

message(STATUS "Download Unified Memory Framework from github.com")

set(UMF_REPO "https://github.com/oneapi-src/unified-memory-framework.git")

# Merge pull request #119 from ldorau/Fix_arena_extent_split_and_arena_extent_merge
set(UMF_TAG 9bf7a0dc4dff76844e10edbb5c6e9d917536ef6d)

message(STATUS "Will fetch Unified Memory Framework from ${UMF_REPO}")

include(FetchContent)
FetchContent_Declare(unified-memory-framework
GIT_REPOSITORY ${UMF_REPO}
GIT_TAG ${UMF_TAG}
)

set(UMF_BUILD_LIBUMF_POOL_DISJOINT ON CACHE INTERNAL "Build Disjoint Pool")
set(UMF_BUILD_OS_MEMORY_PROVIDER OFF CACHE INTERNAL "Build OS Provider")

FetchContent_MakeAvailable(unified-memory-framework)
FetchContent_GetProperties(unified-memory-framework)

target_link_libraries(ur_common PUBLIC
unified_malloc_framework
disjoint_pool
unified-memory-framework::umf
unified-memory-framework::headers
unified-memory-framework::disjoint_pool
${CMAKE_DL_LIBS}
${PROJECT_NAME}::headers
)
Loading

0 comments on commit e3eff58

Please sign in to comment.