#include #include #include #include #include #include #include #include #include #include #include "amdgpu_drm.h" #include "amdgpu.h" #include "amdgpu_drm.h" int main() { struct amdgpu_bo_alloc_request req = {0}; amdgpu_bo_handle buf_handle; uint64_t va1, va2; int fd1, fd2; int major_version, minor_version; int r; amdgpu_device_handle device_handle; amdgpu_va_handle va_handle1, va_handle2; fd1 = open("/dev/dri/card0", O_RDWR | O_CLOEXEC); r = amdgpu_device_initialize(fd1, &major_version, &minor_version, &device_handle); if (r) { printf("device_initialize failed\n"); return r; } req.alloc_size = 4096; req.phys_alignment = 4096; req.preferred_heap = AMDGPU_GEM_DOMAIN_GTT; r = amdgpu_bo_alloc(device_handle, &req, &buf_handle); if (r) { printf("bo allocation failed\n"); return r; } r = amdgpu_va_range_alloc(device_handle, amdgpu_gpu_va_range_general, 4096, 4096, 0, &va1, &va_handle1, 0); if (r) { printf("va alloc failed\n"); return r; } r = amdgpu_bo_va_op(buf_handle, 0, 4096, va1, 0, AMDGPU_VA_OP_MAP); if (r) { printf("va map failed\n"); return r; } fd2 = open("/dev/dri/renderD128", O_RDWR | O_CLOEXEC); r = amdgpu_device_initialize(fd2, &major_version, &minor_version, &device_handle); if (r) { printf("device_initialize failed 2\n"); return r; } req.alloc_size = 4096; req.phys_alignment = 4096; req.preferred_heap = AMDGPU_GEM_DOMAIN_GTT; r = amdgpu_bo_alloc(device_handle, &req, &buf_handle); if (r) { printf("bo allocation failed 2\n"); return r; } r = amdgpu_va_range_alloc(device_handle, amdgpu_gpu_va_range_general, 4096, 4096, 0, &va2, &va_handle2, 0); if (r) { printf("va alloc failed 2\n"); return r; } r = amdgpu_bo_va_op(buf_handle, 0, 4096, va2, 0, AMDGPU_VA_OP_MAP); if (r) { printf("va map failed 2\n"); return r; } }