Files
TheRock/rocm-systems/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmtmodel.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

85 lines
4.2 KiB
C

/*
* Copyright © 2025 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including
* the next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef _HSAKMTMODEL_H_
#define _HSAKMTMODEL_H_
#include <stdbool.h>
#include <stdint.h>
#include <amdgpu.h>
extern bool hsakmt_use_model;
extern char *hsakmt_model_topology;
/**
* Model-mode environment variables (developer/emulation use only):
* HSA_MODEL_TOPOLOGY - Enables model mode when set.
* HSA_MODEL_LIB - Path to the FFM model shared library, resolved as:
* - A relative name or path is always anchored under
* the ROCm install lib directory configured at
* build time (HSAKMT_INSTALL_LIBDIR), e.g.
* "libfoo.so" -> "<HSAKMT_INSTALL_LIBDIR>/libfoo.so".
* It is NOT resolved via the dynamic loader search
* path (LD_LIBRARY_PATH), so a bare soname is taken
* relative to the install dir, not searched.
* - An absolute path under HSAKMT_INSTALL_LIBDIR is
* used as-is.
* - Any other absolute path is honored only in normal
* (unprivileged) processes. Under elevated
* privileges (AT_SECURE, e.g. setuid/setgid or file
* capabilities) it is rejected, preventing arbitrary
* dlopen() across a privilege boundary.
* Paths containing ".." components are always rejected.
*/
void model_init_env_vars(void);
void model_init(void);
int model_kfd_ioctl(unsigned long request, void *arg);
/* DRM/amdgpu wrappers — route to model in model mode, real libdrm otherwise. */
/* BO operations */
int hsakmt_amdgpu_bo_import(amdgpu_device_handle dev, enum amdgpu_bo_handle_type type,
uint32_t shared_handle, struct amdgpu_bo_import_result *output);
int hsakmt_amdgpu_bo_query_info(amdgpu_bo_handle buf_handle, struct amdgpu_bo_info *info);
int hsakmt_amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle, struct amdgpu_bo_metadata *info);
int hsakmt_amdgpu_bo_va_op(amdgpu_bo_handle bo, uint64_t offset, uint64_t size,
uint64_t addr, uint64_t flags, uint32_t ops);
int hsakmt_amdgpu_bo_free(amdgpu_bo_handle buf_handle);
int hsakmt_amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu);
int hsakmt_amdgpu_bo_export(amdgpu_bo_handle buf_handle,
enum amdgpu_bo_handle_type type, uint32_t *shared_handle);
int hsakmt_drm_command_write_read(int fd, unsigned long drmCommandIndex,
void *data, unsigned size);
/* Device-level operations */
int hsakmt_drm_open_render(int minor);
void hsakmt_drm_close(int fd);
int hsakmt_amdgpu_device_initialize(int fd, uint32_t *major_version, uint32_t *minor_version,
amdgpu_device_handle *device_handle);
int hsakmt_amdgpu_device_deinitialize(amdgpu_device_handle device_handle);
int hsakmt_amdgpu_device_get_fd(amdgpu_device_handle dev);
const char *hsakmt_amdgpu_get_marketing_name(amdgpu_device_handle dev);
int hsakmt_amdgpu_query_gpu_info(amdgpu_device_handle dev, struct amdgpu_gpu_info *info);
#endif /* _HSAKMTMODEL_H_ */