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
81 lines
2.5 KiB
C++
81 lines
2.5 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "OCLMapCount.h"
|
|
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "CL/cl.h"
|
|
|
|
OCLMapCount::OCLMapCount() { _numSubTests = 1; }
|
|
|
|
OCLMapCount::~OCLMapCount() {}
|
|
|
|
void OCLMapCount::open(unsigned int test, char* units, double& conversion, unsigned int deviceId) {
|
|
OCLTestImp::open(test, units, conversion, deviceId);
|
|
CHECK_RESULT((error_ != CL_SUCCESS), "Error opening test");
|
|
|
|
size_t size;
|
|
clMemWrapper memObject;
|
|
|
|
// Get the address alignment, so we can make sure the sub buffer test later
|
|
// works properly
|
|
cl_uint addressAlign;
|
|
error_ = _wrapper->clGetDeviceInfo(devices_[deviceId], CL_DEVICE_MEM_BASE_ADDR_ALIGN,
|
|
sizeof(addressAlign), &addressAlign, NULL);
|
|
if (addressAlign < 128) addressAlign = 128;
|
|
|
|
void* void_buffer = malloc(addressAlign * 4);
|
|
|
|
// Create a buffer to test against
|
|
memObject = _wrapper->clCreateBuffer(context_, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
|
|
addressAlign * 4, void_buffer, &error_);
|
|
if (error_) {
|
|
free(void_buffer);
|
|
printf("Unable to create buffer to test");
|
|
}
|
|
|
|
// Map buffer
|
|
void* mapped = _wrapper->clEnqueueMapBuffer(cmdQueues_[deviceId], memObject, true, CL_MAP_READ, 0,
|
|
addressAlign * 4, 0, NULL, NULL, &error_);
|
|
|
|
cl_uint mapCount;
|
|
|
|
// Find the number of mappings on buffer after map
|
|
error_ =
|
|
_wrapper->clGetMemObjectInfo(memObject, CL_MEM_MAP_COUNT, sizeof(mapCount), &mapCount, &size);
|
|
CHECK_RESULT((error_ != CL_SUCCESS), "Unable to get mem object map count");
|
|
if (mapCount != 1) {
|
|
printf(
|
|
"ERROR: Returned mem object map count does not validate! (expected %d, "
|
|
"got %d)\n",
|
|
1, mapCount);
|
|
return;
|
|
}
|
|
|
|
// Unmap buffer
|
|
error_ =
|
|
_wrapper->clEnqueueUnmapMemObject(cmdQueues_[deviceId], memObject, mapped, 0, NULL, NULL);
|
|
|
|
// Find the number of mappings on buffer after unmap
|
|
error_ =
|
|
_wrapper->clGetMemObjectInfo(memObject, CL_MEM_MAP_COUNT, sizeof(mapCount), &mapCount, &size);
|
|
CHECK_RESULT((error_ != CL_SUCCESS), "Unable to get mem object map count");
|
|
if (mapCount != 0) {
|
|
printf(
|
|
"ERROR: Returned mem object map count does not validate! (expected %d, "
|
|
"got %d)\n",
|
|
0, mapCount);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void OCLMapCount::run(void) {}
|
|
|
|
unsigned int OCLMapCount::close(void) { return OCLTestImp::close(); }
|