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
100 lines
2.9 KiB
C++
100 lines
2.9 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
/**
|
|
* @addtogroup hipMemMapArrayAsync hipMemMapArrayAsync
|
|
* @{
|
|
* @ingroup VirtualMemoryManagementTest
|
|
* `hipError_t hipMemMapArrayAsync(hipArrayMapInfo *mapInfoList,
|
|
* unsigned int count,
|
|
* hipStream_t stream)` -
|
|
* Maps or unmaps subregions of sparse HIP arrays and sparse HIP mipmapped arrays.
|
|
*/
|
|
|
|
#include <hip_array_common.hh>
|
|
#include <hip_test_common.hh>
|
|
#include <resource_guards.hh>
|
|
|
|
#include "hip_vmm_common.hh"
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Basic sanity test.
|
|
* ------------------------
|
|
* - unit/virtualMemoryManagement/hipMemMapArrayAsync.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 6.1
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipMemMapArrayAsync_Positive_Basic) {
|
|
HIP_CHECK(hipFree(0));
|
|
|
|
hipDevice_t device;
|
|
HIP_CHECK(hipDeviceGet(&device, 0));
|
|
checkVMMSupported(device);
|
|
|
|
CHECK_IMAGE_SUPPORT;
|
|
|
|
hipmipmappedArray array;
|
|
|
|
HIP_ARRAY3D_DESCRIPTOR desc = {};
|
|
using vec_info = vector_info<float>;
|
|
desc.Format = vec_info::format;
|
|
desc.NumChannels = vec_info::size;
|
|
desc.Width = 1;
|
|
desc.Height = 1;
|
|
desc.Flags = CUDA_ARRAY3D_SPARSE;
|
|
|
|
unsigned int levels = 2;
|
|
|
|
HIP_CHECK(hipMipmappedArrayCreate(&array, &desc, levels));
|
|
|
|
hipMemAllocationProp prop = {};
|
|
prop.type = hipMemAllocationTypePinned;
|
|
prop.location.type = hipMemLocationTypeDevice;
|
|
prop.location.id = device;
|
|
prop.allocFlags.usage = CU_MEM_CREATE_USAGE_TILE_POOL;
|
|
|
|
size_t granularity;
|
|
HIP_CHECK(
|
|
hipMemGetAllocationGranularity(&granularity, &prop, hipMemAllocationGranularityRecommended));
|
|
|
|
hipMemGenericAllocationHandle_t handle;
|
|
HIP_CHECK(hipMemCreate(&handle, granularity, &prop, 0));
|
|
|
|
hipArrayMapInfo map_info_list = {};
|
|
map_info_list.resourceType = HIP_RESOURCE_TYPE_MIPMAPPED_ARRAY;
|
|
map_info_list.resource.mipmap = array;
|
|
map_info_list.subresourceType = hipArraySparseSubresourceTypeSparseLevel;
|
|
map_info_list.subresource.sparseLevel.extentWidth = 1;
|
|
map_info_list.subresource.sparseLevel.extentHeight = 1;
|
|
map_info_list.subresource.sparseLevel.extentDepth = 1;
|
|
map_info_list.memOperationType = hipMemOperationTypeMap;
|
|
map_info_list.memHandleType = hipMemHandleTypeGeneric;
|
|
map_info_list.memHandle.memHandle = handle;
|
|
map_info_list.deviceBitMask = 0x1;
|
|
|
|
StreamGuard stream(Streams::created);
|
|
|
|
HIP_CHECK(hipMemMapArrayAsync(&map_info_list, 1, stream.stream()));
|
|
HIP_CHECK(hipStreamSynchronize(stream.stream()));
|
|
|
|
map_info_list.memOperationType = hipMemOperationTypeUnmap;
|
|
map_info_list.memHandle.memHandle = NULL;
|
|
HIP_CHECK(hipMemMapArrayAsync(&map_info_list, 1, stream.stream()));
|
|
HIP_CHECK(hipStreamSynchronize(stream.stream()));
|
|
|
|
HIP_CHECK(hipMemRelease(handle));
|
|
|
|
HIP_CHECK(hipMipmappedArrayDestroy(array));
|
|
}
|
|
|
|
/**
|
|
* End doxygen group VirtualMemoryManagementTest.
|
|
* @}
|
|
*/
|