Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ac615db
[SYCL][HIP] Port HIP plugin to Unified Runtime (#9617)
omarahmed1111 Jul 13, 2023
e56d66b
[SYCL][UR][HIP] remove unused parameter in ur hip (#10357)
omarahmed1111 Jul 13, 2023
02fe07c
[SYCL][UR] Fix device partition queries (#10355)
Jul 19, 2023
1daa6b0
[SYCL] [L0] Add user APIs to import / release host memory from USM. (…
rdeodhar Jul 19, 2023
633a2f0
[HIP][UR] Use primary context in HIP adapter (#10514)
hdelan Jul 26, 2023
d618fb7
[SYCL][PI] Restore CUDA and HIP plugin ABI (#10518)
kbenzie Jul 27, 2023
3ca5fba
[SYCL][UR] Bump UR and implement adapter handles (#10349)
callumfare Jul 28, 2023
c3280d9
[CUDA][HIP][UR] Fix race condition in adapters (#10826)
hdelan Aug 18, 2023
f02aa8f
Add prefetch for HIP USM allocations (#10430)
ldrumm Aug 24, 2023
503755d
[UR][CUDA][HIP] Fix Set Arg Local (#10710)
veselypeta Aug 25, 2023
9d5d494
[SYCL][UR][HIP] Check if module needs to be unloaded (#10787)
veselypeta Aug 28, 2023
e0c87a5
[UR][CUDA][HIP][L0] Cleanup licence header (#10824)
veselypeta Aug 28, 2023
e3d2184
[SYCL][HIP] Implemented supported make_* interop functions. (#10526)
JackAKirk Aug 30, 2023
68faafa
[SYCL][HIP] Add managed memory USM checks for HIP prefetch (#10761)
Sep 4, 2023
8639075
[UR][CUDA][HIP] Replace `ur::assertion` with `UR_CHECK_ERROR` (#10986)
JackAKirk Sep 8, 2023
73527bc
[SYCL][UR] Implement usm memory pool for hip adapter. (#11065)
martygrant Sep 12, 2023
e08d63b
[SYCL][UR] Remove unused MaxAllocSize member variable and fix unused …
martygrant Sep 12, 2023
0b56545
[PI][UR][HIP][CUDA][L0][NCPU] Pull in latest UR fixes. (#11155)
veselypeta Sep 15, 2023
5c1d65e
[SYCL] Add esimd as an optional device feature (#10017)
sarnex Sep 19, 2023
eb86b33
Revert "[PI][UR][HIP][CUDA][L0][NCPU] Pull in latest UR fixes." (#11227)
aelovikov-intel Sep 20, 2023
cca22fa
[SYCL][HIP] Fix hip prefetch/mem_advise (noop) for rocm < 5.0 (#10958)
JackAKirk Sep 21, 2023
834e127
[SYCL][NFC] Make UR_CHECK_ERROR a void return macro (#11100)
Sep 22, 2023
f5e0ed5
[SYCL] Fix uninitialized variables (#11289)
Sep 25, 2023
899f831
Merge branch 'tmp_hip' into petr/move_hip
veselypeta Sep 28, 2023
2cc31e5
[UR][HIP] Copy adapter code from intel/llvm
veselypeta Sep 28, 2023
20297af
[UR][HIP] Fixup licenses and loader interface
veselypeta Sep 28, 2023
fbd14e1
[UR] Fix include path
veselypeta Sep 28, 2023
48a03ac
[HIP][UR] Fix hip include dir
veselypeta Sep 28, 2023
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: 0 additions & 2 deletions source/adapters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ if(UR_BUILD_ADAPTER_CUDA)
endif()

if(UR_BUILD_ADAPTER_HIP)
set(SYCL_ADAPTER_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/hip")
FetchSource(https://github.com/intel/llvm.git ${INTEL_LLVM_TAG} "sycl/plugins/unified_runtime/ur" ${SYCL_ADAPTER_DIR})
add_subdirectory(hip)
endif()

Expand Down
4 changes: 4 additions & 0 deletions source/adapters/hip/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
Language: Cpp
BasedOnStyle: LLVM
...
65 changes: 33 additions & 32 deletions source/adapters/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(HIP_DIR "${SYCL_ADAPTER_DIR}/sycl/plugins/unified_runtime/ur/adapters/hip" CACHE PATH "HIP adapter directory")
set(HIP_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "HIP adapter directory")

set(TARGET_NAME ur_adapter_hip)

Expand Down Expand Up @@ -44,36 +44,37 @@ set(HIP_HEADERS "${UR_HIP_INCLUDE_DIR};${UR_HIP_HSA_INCLUDE_DIR}")

add_ur_adapter(${TARGET_NAME}
SHARED
${HIP_DIR}/ur_interface_loader.cpp
${HIP_DIR}/adapter.hpp
${HIP_DIR}/adapter.cpp
${HIP_DIR}/command_buffer.hpp
${HIP_DIR}/command_buffer.cpp
${HIP_DIR}/common.hpp
${HIP_DIR}/common.cpp
${HIP_DIR}/context.hpp
${HIP_DIR}/context.cpp
${HIP_DIR}/device.hpp
${HIP_DIR}/device.cpp
${HIP_DIR}/enqueue.cpp
${HIP_DIR}/event.hpp
${HIP_DIR}/event.cpp
${HIP_DIR}/kernel.hpp
${HIP_DIR}/kernel.cpp
${HIP_DIR}/memory.hpp
${HIP_DIR}/memory.cpp
${HIP_DIR}/platform.hpp
${HIP_DIR}/platform.cpp
${HIP_DIR}/program.hpp
${HIP_DIR}/program.cpp
${HIP_DIR}/queue.hpp
${HIP_DIR}/queue.cpp
${HIP_DIR}/sampler.hpp
${HIP_DIR}/sampler.cpp
${HIP_DIR}/usm.cpp
${HIP_DIR}/usm_p2p.cpp
${HIP_DIR}/../../ur.cpp
${HIP_DIR}/../../ur.hpp
${CMAKE_CURRENT_SOURCE_DIR}/ur_interface_loader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/adapter.hpp
${CMAKE_CURRENT_SOURCE_DIR}/adapter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.hpp
${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common.hpp
${CMAKE_CURRENT_SOURCE_DIR}/common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/context.hpp
${CMAKE_CURRENT_SOURCE_DIR}/context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device.hpp
${CMAKE_CURRENT_SOURCE_DIR}/device.cpp
${CMAKE_CURRENT_SOURCE_DIR}/enqueue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/event.hpp
${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel.hpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory.hpp
${CMAKE_CURRENT_SOURCE_DIR}/memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platform.hpp
${CMAKE_CURRENT_SOURCE_DIR}/platform.cpp
${CMAKE_CURRENT_SOURCE_DIR}/program.hpp
${CMAKE_CURRENT_SOURCE_DIR}/program.cpp
${CMAKE_CURRENT_SOURCE_DIR}/queue.hpp
${CMAKE_CURRENT_SOURCE_DIR}/queue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sampler.hpp
${CMAKE_CURRENT_SOURCE_DIR}/sampler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/usm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/usm_p2p.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
)

if(NOT MSVC)
Expand Down Expand Up @@ -148,5 +149,5 @@ else()
endif()

target_include_directories(${TARGET_NAME} PRIVATE
${HIP_DIR}/../../../
"${CMAKE_CURRENT_SOURCE_DIR}/../../"
)
80 changes: 80 additions & 0 deletions source/adapters/hip/adapter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//===--------- adapter.cpp - HIP Adapter ----------------------------------===//
//
// Copyright (C) 2023 Intel Corporation
//
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "adapter.hpp"
#include "common.hpp"

#include <atomic>
#include <ur_api.h>

struct ur_adapter_handle_t_ {
std::atomic<uint32_t> RefCount = 0;
};

ur_adapter_handle_t_ adapter{};

UR_APIEXPORT ur_result_t UR_APICALL urInit(ur_device_init_flags_t,
ur_loader_config_handle_t) {
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urTearDown(void *) {
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urAdapterGet(
uint32_t, ur_adapter_handle_t *phAdapters, uint32_t *pNumAdapters) {
if (phAdapters) {
adapter.RefCount++;
*phAdapters = &adapter;
}
if (pNumAdapters) {
*pNumAdapters = 1;
}

return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) {
// No state to clean up so we don't need to check for 0 references
adapter.RefCount--;
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urAdapterRetain(ur_adapter_handle_t) {
adapter.RefCount++;
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetLastError(
ur_adapter_handle_t, const char **ppMessage, int32_t *pError) {
*ppMessage = ErrorMessage;
*pError = ErrorMessageCode;
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
ur_adapter_info_t propName,
size_t propSize,
void *pPropValue,
size_t *pPropSizeRet) {
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);

switch (propName) {
case UR_ADAPTER_INFO_BACKEND:
return ReturnValue(UR_ADAPTER_BACKEND_HIP);
case UR_ADAPTER_INFO_REFERENCE_COUNT:
return ReturnValue(adapter.RefCount.load());
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

return UR_RESULT_SUCCESS;
}
13 changes: 13 additions & 0 deletions source/adapters/hip/adapter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===--------- adapter.hpp - HIP Adapter ----------------------------------===//
//
// Copyright (C) 2023 Intel Corporation
//
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

struct ur_adapter_handle_t_;

extern ur_adapter_handle_t_ adapter;
131 changes: 131 additions & 0 deletions source/adapters/hip/command_buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//===--------- command_buffer.cpp - HIP Adapter ---------------------------===//
//
// Copyright (C) 2023 Intel Corporation
//
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "command_buffer.hpp"
#include "common.hpp"

/// Stub implementations of UR experimental feature command-buffers

UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
ur_context_handle_t, ur_device_handle_t,
const ur_exp_command_buffer_desc_t *, ur_exp_command_buffer_handle_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL
urCommandBufferRetainExp(ur_exp_command_buffer_handle_t) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL
urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL
urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(
ur_exp_command_buffer_handle_t, ur_kernel_handle_t, uint32_t,
const size_t *, const size_t *, const size_t *, uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemcpyUSMExp(
ur_exp_command_buffer_handle_t, void *, const void *, size_t, uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyExp(
ur_exp_command_buffer_handle_t, ur_mem_handle_t, ur_mem_handle_t, size_t,
size_t, size_t, uint32_t, const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyRectExp(
ur_exp_command_buffer_handle_t, ur_mem_handle_t, ur_mem_handle_t,
ur_rect_offset_t, ur_rect_offset_t, ur_rect_region_t, size_t, size_t,
size_t, size_t, uint32_t, const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT
ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteExp(
ur_exp_command_buffer_handle_t, ur_mem_handle_t, size_t, size_t,
const void *, uint32_t, const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT
ur_result_t UR_APICALL urCommandBufferAppendMembufferReadExp(
ur_exp_command_buffer_handle_t, ur_mem_handle_t, size_t, size_t, void *,
uint32_t, const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT
ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteRectExp(
ur_exp_command_buffer_handle_t, ur_mem_handle_t, ur_rect_offset_t,
ur_rect_offset_t, ur_rect_region_t, size_t, size_t, size_t, size_t, void *,
uint32_t, const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT
ur_result_t UR_APICALL urCommandBufferAppendMembufferReadRectExp(
ur_exp_command_buffer_handle_t, ur_mem_handle_t, ur_rect_offset_t,
ur_rect_offset_t, ur_rect_region_t, size_t, size_t, size_t, size_t, void *,
uint32_t, const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
ur_exp_command_buffer_handle_t, ur_queue_handle_t, uint32_t,
const ur_event_handle_t *, ur_event_handle_t *) {
detail::ur::die("Experimental Command-buffer feature is not "
"implemented for HIP adapter.");
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
15 changes: 15 additions & 0 deletions source/adapters/hip/command_buffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//===--------- command_buffer.hpp - HIP Adapter ---------------------------===//
//
// Copyright (C) 2023 Intel Corporation
//
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <ur/ur.hpp>

/// Stub implementation of command-buffers for HIP

struct ur_exp_command_buffer_handle_t_ {};
Loading