* libhsakmt/virtio: Add alloc memory align api Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Rename CLGL BO to AMDGPU BO Rename VHSA_BO_CLGL to VHSA_BO_AMDGPU to support generic AMDGPU buffer objects, not just CL/GL interop. * libhsakmt/virtio: Add atomic helpers and node lookup Add vhsakmt_atomic_inc/dec macros and vhsakmt_get_node_by_id helper function. * libhsakmt/virtio: Add AMDGPU device initialization support Add vamdgpu_device_initialize and vamdgpu_device_deinitialize functions. * libhsakmt/virtio: Add AMDGPU device handle and DRM command support Add vamdgpu_device_get_fd, vdrmCommandWriteRead and update vhsaKmtGetAMDGPUDeviceHandle. * libhsakmt/virtio: Add AMDGPU BO free and CPU map support Add vamdgpu_bo_free and vamdgpu_bo_cpu_map functions. * libhsakmt/virtio: Add AMDGPU BO import and export support Add vamdgpu_bo_import, vamdgpu_bo_export and vhsakmt_bo_from_resid functions. * libhsakmt/virtio: Add AMDGPU BO VA operation support Add vamdgpu_bo_va_op function. * libhsakmt/virtio: Add dma buf export support Add vhsaKmtExportDMABufHandle API in virtio driver to support export feature. * libhsakmt/virtio: Fix potential deadlock in userptr deregistration Refactor vhsakmt_deregister_userptr_non_svm to avoid calling vhsakmt_destroy_userptr while holding the bo_handles_mutex lock. Previously, destroying userptrs directly while iterating the tree could cause deadlock issues due to nested locking. - Move interval tree removal from vhsakmt_destroy_userptr to caller - Collect BOs to free in a temporary array during tree traversal - Destroy BOs after releasing the mutex to avoid lock contention - Use dynamic array with realloc to handle arbitrary number of BOs Signed-off-by: Honglei Huang <honghuan@amd.com> * rocr: driver/virtio: Implement DMA-BUF import/export and memory mapping APIs Implement the missing DMA-BUF handling and memory mapping functions in the virtio KFD driver to enable cross-process memory sharing: - ExportDMABuf: Export HSA memory as DMA-BUF file descriptor - ImportDMABuf: Import DMA-BUF fd as shareable buffer object - Map: Map imported buffer into virtual address space with permissions - Unmap: Unmap buffer from virtual address space - ReleaseShareableHandle: Free imported buffer object Also add drm_perm() helper to convert HSA access permissions to AMDGPU VM page flags (READABLE/WRITEABLE). These APIs enable IPC memory sharing between HSA processes through DMA-BUF mechanism in virtualized environments. Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add register memory APIs Add two new memory registration functions to the virtio HSA KMT library: 1. vhsaKmtRegisterMemory: A simplified wrapper for vhsaKmtRegisterMemoryWithFlags that uses default CoarseGrain memory flags. 2. vhsaKmtRegisterMemoryToNodes: A stub implementation for registering memory to specific nodes. Returns HSAKMT_STATUS_NOT_IMPLEMENTED as it's currently not used in ROCR. Changes: - Added function declarations in hsakmt_virtio.h - Implemented functions in hsakmt_virtio_memory.c - Exported symbols in libhsakmt_virtio.ver Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add graphics handle registration and mapping APIs - Add vhsaKmtRegisterGraphicsHandleToNodesExt() with flags support - Add vhsaKmtMapGraphicHandle() and vhsaKmtUnmapGraphicHandle() stubs - Refactor existing registration API to use extended version Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add virtio support for queue APIs Implement vhsaKmtUpdateQueue, vhsaKmtSetQueueCUMask, vhsaKmtAllocQueueGWS and vhsaKmtGetQueueInfo functions with virtio protocol extensions and symbol exports. Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add new virtio API support for model, SMI, and XNACK mode Add three new API functions to the virtio backend: - vhsaKmtModelEnabled: Check if pre-silicon model is enabled (returns false for virtio) - vhsaKmtOpenSMI: Open SMI interface for a node (not yet supported in virtio) - vhsaKmtSetXNACKMode: Set XNACK mode via virtio control command Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add shared memory support for virtio backend Implement shared memory APIs for the virtio backend to enable memory sharing between processes: - Add vhsaKmtShareMemory() to share memory regions and create shared memory handles - Add vhsaKmtRegisterSharedHandle() to register shared memory handles in the current process - Add vhsaKmtRegisterSharedHandleToNodes() for node-specific shared memory registration Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add memory management APIs for virtio Add the following new memory management APIs to virtio implementation: - vhsaKmtSetMemoryUserData: Set user data for memory pointer - vhsaKmtSetMemoryPolicy: Configure memory policy for nodes - vhsaKmtSVMGetAttr: Get SVM (Shared Virtual Memory) attributes - vhsaKmtSVMSetAttr: Set SVM attributes - vhsaKmtReplaceAsanHeaderPage: ASAN header page replacement (stub) - vhsaKmtReturnAsanHeaderPage: ASAN header page return (stub) Changes include: - Added API declarations in hsakmt_virtio.h - Implemented functions in hsakmt_virtio_memory.c - Extended protocol definitions in hsakmt_virtio_proto.h - Added user_data field to vhsakmt_bo structure - Exported new symbols in libhsakmt_virtio.ver Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add SPM APIs Add three new SPM-related APIs to the virtio interface: - vhsaKmtSPMAcquire: Acquire SPM resources on a preferred node - vhsaKmtSPMRelease: Release SPM resources on a preferred node - vhsaKmtSPMSetDestBuffer: Set destination buffer for SPM data with optional userptr support and data loss detection These APIs extend the virtio command protocol with new query types: - VHSAKMT_CCMD_QUERY_SPM_ACQUIRE - VHSAKMT_CCMD_QUERY_SPM_RELEASE - VHSAKMT_CCMD_QUERY_SPM_SET_DST_BUFFER The implementation includes proper buffer management for both direct BO access and userptr fallback for smaller buffers. Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add virtio stub for hsaKmtAisReadWriteFile API Add vhsaKmtAisReadWriteFile stub implementation for the virtio backend to support AIS (Accelerated I/O Service) file read/write operations. This stub currently returns HSAKMT_STATUS_NOT_IMPLEMENTED. Changes include: - Add vhsaKmtAisReadWriteFile declaration in hsakmt_virtio.h - Add stub implementation in hsakmt_virtio_memory.c - Export the symbol in libhsakmt_virtio.ver Signed-off-by: energystoryhhl <energystoryhhl@users.noreply.github.com> * libhsakmt/virtio: Add vamdgpu_bo_query_info and vamdgpu_bo_set_metadata APIs Implement two new virtio wrapper functions for AMDGPU buffer object operations: 1. vamdgpu_bo_query_info: Query buffer object information including allocation parameters, memory usage, and metadata. 2. vamdgpu_bo_set_metadata: Set metadata for a buffer object, allowing applications to attach custom data to GPU memory allocations. Signed-off-by: Honglei Huang <honghuan@amd.com> * libhsakmt/virtio: Add ProcessVMRead/Write stub implementations for virtio Add vhsaKmtProcessVMRead and vhsaKmtProcessVMWrite stub functions to the virtio interface. These APIs return HSAKMT_STATUS_NOT_IMPLEMENTED since they are not supported in the baremetal implementation, matching the behavior of the deprecated hsaKmtProcessVMRead/Write APIs. Signed-off-by: energystoryhhl <energystoryhhl@users.noreply.github.com> --------- Signed-off-by: Honglei Huang <honghuan@amd.com> Signed-off-by: energystoryhhl <energystoryhhl@users.noreply.github.com> Co-authored-by: energystoryhhl <energystoryhhl@users.noreply.github.com>
ROCt Library
This repository includes the user-mode API interfaces used to interact with the ROCk driver.
Starting at 1.7 release, ROCt uses drm render device. This requires the user to belong to video group. Add the user account to video group with "sudo usermod -a -G video username" command if the user if not part of video group yet. NOTE: Users of Ubuntu 20.04 will need to add the user to the new "render" group, as Ubuntu has changed the owner:group of /dev/kfd to render:render as of that release
ROCk Driver
The ROCt library is not a standalone product and requires that you have the correct ROCk driver installed, or are using a compatible upstream kernel. Please refer to https://rocm.docs.amd.com under "Getting Started Guide" for a list of supported Operating Systems and kernel versions, as well as supported hardware.
Building the Thunk
A simple cmake-based system is available for building thunk. To build the thunk from the the ROCT-Thunk-Interface directory, execute:
mkdir -p build
cd build
cmake ..
make
If the hsakmt-roct and hsakmt-roct-dev packages are desired:
mkdir -p build
cd build
cmake ..
make package
If you choose not to build and install packages, manual installation of the binaries and header files can be done via:
make install
NOTE: For older versions of the thunk where hsakmt-dev.txt is present, "make package-dev" and "make install-dev" are required to generate/install the developer packages. Currently, these are created via the "make package" and "make install" commands
Disclaimer
The information contained herein is for informational purposes only, and is subject to change without notice. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation or use of AMD hardware, software or other products described herein. No license, including implied or arising by estoppel, to any intellectual property rights is granted by this document. Terms and limitations applicable to the purchase or use of AMD's products are as set forth in a signed agreement between the parties or in AMD's Standard Terms and Conditions of Sale.
AMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies.
Copyright (c) 2014-2023 Advanced Micro Devices, Inc. All rights reserved.