SWDEV-377991 - Remove liquidflash support

Change-Id: I928ed40f11461d5da07190e67bbec6a5363c42a6
This commit is contained in:
German
2023-01-19 11:14:17 -05:00
parent a4c174e269
commit b9901144eb
13 changed files with 2 additions and 968 deletions
-1
View File
@@ -81,7 +81,6 @@ target_sources(amdocl PRIVATE
cl_gl.cpp
cl_icd.cpp
cl_kernel_info_amd.cpp
cl_lqdflash_amd.cpp
cl_memobj.cpp
cl_p2p_amd.cpp
cl_pipe.cpp
+1 -16
View File
@@ -34,7 +34,6 @@
#include "cl_platform_amd.h"
#include "cl_sdi_amd.h"
#include "cl_thread_trace_amd.h"
#include "cl_lqdflash_amd.h"
#include "cl_p2p_amd.h"
#include <GL/gl.h>
@@ -489,9 +488,6 @@ CL_API_ENTRY void* CL_API_CALL clGetExtensionFunctionAddress(const char* func_na
#if cl_amd_assembly_program
CL_EXTENSION_ENTRYPOINT_CHECK(clCreateProgramWithAssemblyAMD);
#endif // cl_amd_assembly_program
#if cl_amd_liquid_flash
CL_EXTENSION_ENTRYPOINT_CHECK(clCreateSsgFileObjectAMD);
#endif // cl_amd_liquid_flash
break;
case 'D':
break;
@@ -511,13 +507,9 @@ CL_API_ENTRY void* CL_API_CALL clGetExtensionFunctionAddress(const char* func_na
CL_EXTENSION_ENTRYPOINT_CHECK(clEnqueueWaitSignalAMD);
CL_EXTENSION_ENTRYPOINT_CHECK(clEnqueueWriteSignalAMD);
CL_EXTENSION_ENTRYPOINT_CHECK(clEnqueueMakeBuffersResidentAMD);
#if cl_amd_liquid_flash
CL_EXTENSION_ENTRYPOINT_CHECK(clEnqueueReadSsgFileAMD);
CL_EXTENSION_ENTRYPOINT_CHECK(clEnqueueWriteSsgFileAMD);
#endif // cl_amd_liquid_flash
#if cl_amd_copy_buffer_p2p
CL_EXTENSION_ENTRYPOINT_CHECK(clEnqueueCopyBufferP2PAMD);
#endif // cl_amd_liquid_flash
#endif // cl_amd_copy_buffer_p2p
break;
case 'G':
CL_EXTENSION_ENTRYPOINT_CHECK(clGetKernelInfoAMD);
@@ -534,9 +526,6 @@ CL_API_ENTRY void* CL_API_CALL clGetExtensionFunctionAddress(const char* func_na
#if defined(cl_khr_sub_groups) || defined(CL_VERSION_2_1)
CL_EXTENSION_ENTRYPOINT_CHECK2(clGetKernelSubGroupInfoKHR,clGetKernelSubGroupInfo);
#endif // defined(cl_khr_sub_groups) || defined(CL_VERSION_2_1)
#if cl_amd_liquid_flash
CL_EXTENSION_ENTRYPOINT_CHECK(clGetSsgFileObjectInfoAMD);
#endif // cl_amd_liquid_flash
break;
case 'I':
CL_EXTENSION_ENTRYPOINT_CHECK(clIcdGetPlatformIDsKHR);
@@ -546,10 +535,6 @@ CL_API_ENTRY void* CL_API_CALL clGetExtensionFunctionAddress(const char* func_na
CL_EXTENSION_ENTRYPOINT_CHECK(clRetainPerfCounterAMD);
CL_EXTENSION_ENTRYPOINT_CHECK(clReleaseThreadTraceAMD);
CL_EXTENSION_ENTRYPOINT_CHECK(clRetainThreadTraceAMD);
#if cl_amd_liquid_flash
CL_EXTENSION_ENTRYPOINT_CHECK(clRetainSsgFileObjectAMD);
CL_EXTENSION_ENTRYPOINT_CHECK(clReleaseSsgFileObjectAMD);
#endif // cl_amd_liquid_flash
break;
case 'S':
CL_EXTENSION_ENTRYPOINT_CHECK(clSetThreadTraceParamAMD);
-312
View File
@@ -1,312 +0,0 @@
/* Copyright (c) 2015 - 2021 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 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. */
#include "cl_common.hpp"
#include <CL/cl_ext.h>
#include "platform/object.hpp"
#include "cl_lqdflash_amd.h"
#ifndef WITH_LIQUID_FLASH
#if (!defined(BUILD_HSA_TARGET) && defined(WITH_HSA_DEVICE) && \
defined(WITH_AMDGPU_PRO)) || defined(_WIN32)
#define WITH_LIQUID_FLASH 1
#endif // _WIN32
#endif
#if WITH_LIQUID_FLASH
#include "lf.h"
#include <locale>
#include <codecvt>
#endif // WITH_LIQUID_FLASH
namespace amd {
LiquidFlashFile::~LiquidFlashFile() { close(); }
bool LiquidFlashFile::open() {
#if WITH_LIQUID_FLASH
lf_status err;
lf_file_flags flags = 0;
switch (flags_) {
case CL_FILE_READ_ONLY_AMD:
flags = LF_READ;
break;
case CL_FILE_WRITE_ONLY_AMD:
flags = LF_WRITE;
break;
case CL_FILE_READ_WRITE_AMD:
flags = LF_READ | LF_WRITE;
break;
}
#ifdef __linux__
assert(sizeof(wchar_t) != sizeof(lf_char));
std::string name_char;
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> cv;
name_char = cv.to_bytes(name_);
handle_ = lfOpenFile(name_char.c_str(), flags, &err);
#else
handle_ = lfOpenFile(name_.c_str(), flags, &err);
#endif
if (err != lf_success) {
return false;
}
if (lfGetFileBlockSize((lf_file)handle_, &blockSize_) != lf_success) {
return false;
}
if (lfGetFileSize((lf_file)handle_, &fileSize_) != lf_success) {
return false;
}
return true;
#else
return false;
#endif // WITH_LIQUID_FLASH
}
void LiquidFlashFile::close() {
#if WITH_LIQUID_FLASH
if (handle_ != NULL) {
lfReleaseFile((lf_file)handle_);
handle_ = NULL;
}
#endif // WITH_LIQUID_FLASH
}
bool LiquidFlashFile::transferBlock(bool writeBuffer, void* srcDst, uint64_t bufferSize,
uint64_t fileOffset, uint64_t bufferOffset,
uint64_t size) const {
#if WITH_LIQUID_FLASH
lf_status status;
lf_region_descriptor region = {fileOffset / blockSize(), bufferOffset / blockSize(),
size / blockSize()};
if (writeBuffer) {
status = lfReadFile(srcDst, bufferSize, (lf_file)handle_, 1, &region, NULL);
} else {
status = lfWriteFile(srcDst, bufferSize, (lf_file)handle_, 1, &region, NULL);
}
if (lf_success == status) {
return true;
} else {
return false;
}
#else
return false;
#endif // WITH_LIQUID_FLASH
}
} // namespace amd
/*! \addtogroup API
* @{
*
* \addtogroup AMD_Extensions
* @{
*
*/
RUNTIME_ENTRY_RET(cl_file_amd, clCreateSsgFileObjectAMD,
(cl_context context, cl_file_flags_amd flags, const wchar_t* file_name,
cl_int* errcode_ret)) {
#if WITH_LIQUID_FLASH && defined __linux__
if (!is_valid(context)) {
*not_null(errcode_ret) = CL_INVALID_CONTEXT;
LogWarning("invalid parameter \"context\"");
return (cl_file_amd)0;
}
const std::vector<amd::Device*>& devices = as_amd(context)->devices();
bool supportPass = false;
for (auto& dev : devices) {
if (lf_success == lfCheckExtensionSupportForDevice(dev->info().pcieDeviceId_,
dev->info().pcieRevisionId_)) {
supportPass = true;
break;
}
}
if (!supportPass) {
*not_null(errcode_ret) = CL_INVALID_DEVICE;
LogWarning("SSG isn't supported");
return (cl_file_amd)0;
}
#endif
amd::LiquidFlashFile* file = new amd::LiquidFlashFile(file_name, flags);
if (file == NULL) {
*not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY;
return (cl_file_amd)0;
}
if (!file->open()) {
*not_null(errcode_ret) = CL_INVALID_VALUE;
delete file;
return (cl_file_amd)0;
}
*not_null(errcode_ret) = CL_SUCCESS;
return as_cl(file);
}
RUNTIME_EXIT
RUNTIME_ENTRY(cl_int, clGetSsgFileObjectInfoAMD,
(cl_file_amd file, cl_file_info_amd param_name, size_t param_value_size,
void* param_value, size_t* param_value_size_ret)) {
if (!is_valid(file)) {
return CL_INVALID_FILE_OBJECT_AMD;
}
switch (param_name) {
case CL_FILE_BLOCK_SIZE_AMD: {
cl_uint blockSize = as_amd(file)->blockSize();
return amd::clGetInfo(blockSize, param_value_size, param_value, param_value_size_ret);
}
case CL_FILE_SIZE_AMD: {
cl_ulong fileSize = as_amd(file)->fileSize();
return amd::clGetInfo(fileSize, param_value_size, param_value, param_value_size_ret);
}
default:
break;
}
return CL_INVALID_VALUE;
}
RUNTIME_EXIT
RUNTIME_ENTRY(cl_int, clRetainSsgFileObjectAMD, (cl_file_amd file)) {
if (!is_valid(file)) {
return CL_INVALID_FILE_OBJECT_AMD;
}
as_amd(file)->retain();
return CL_SUCCESS;
}
RUNTIME_EXIT
RUNTIME_ENTRY(cl_int, clReleaseSsgFileObjectAMD, (cl_file_amd file)) {
if (!is_valid(file)) {
return CL_INVALID_FILE_OBJECT_AMD;
}
as_amd(file)->release();
return CL_SUCCESS;
}
RUNTIME_EXIT
static cl_int EnqueueTransferBufferFromSsgFileAMD(
cl_bool isWrite, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write,
size_t buffer_offset, size_t cb, cl_file_amd file, size_t file_offset,
cl_uint num_events_in_wait_list, const cl_event* event_wait_list, cl_event* event) {
if (!is_valid(command_queue)) {
return CL_INVALID_COMMAND_QUEUE;
}
if (!is_valid(buffer)) {
return CL_INVALID_MEM_OBJECT;
}
amd::Buffer* pBuffer = as_amd(buffer)->asBuffer();
if (pBuffer == NULL) {
return CL_INVALID_MEM_OBJECT;
}
if (pBuffer->getMemFlags() & (CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS)) {
return CL_INVALID_OPERATION;
}
amd::HostQueue* queue = as_amd(command_queue)->asHostQueue();
if (NULL == queue) {
return CL_INVALID_COMMAND_QUEUE;
}
amd::HostQueue& hostQueue = *queue;
if (hostQueue.context() != pBuffer->getContext()) {
return CL_INVALID_CONTEXT;
}
if (!is_valid(file)) {
return CL_INVALID_FILE_OBJECT_AMD;
}
amd::LiquidFlashFile* amdFile = as_amd(file);
amd::Coord3D bufferOffset(buffer_offset, 0, 0);
amd::Coord3D bufferSize(cb, 1, 1);
if ((!pBuffer->validateRegion(bufferOffset, bufferSize)) ||
// LF library supports aligned sizes only
((buffer_offset % amdFile->blockSize()) != 0) || ((cb % amdFile->blockSize()) != 0) ||
((file_offset % amdFile->blockSize()) != 0)) {
return CL_INVALID_VALUE;
}
amd::Command::EventWaitList eventWaitList;
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
event_wait_list);
if (err != CL_SUCCESS) {
return err;
}
amd::TransferBufferFileCommand* command;
command = new amd::TransferBufferFileCommand(
isWrite ? CL_COMMAND_READ_SSG_FILE_AMD : CL_COMMAND_WRITE_SSG_FILE_AMD, hostQueue,
eventWaitList, *pBuffer, bufferOffset, bufferSize, amdFile, file_offset);
if (command == NULL) {
return CL_OUT_OF_HOST_MEMORY;
}
// Make sure we have memory for the command execution
if (!command->validateMemory()) {
delete command;
return CL_MEM_OBJECT_ALLOCATION_FAILURE;
}
command->enqueue();
if (blocking_write) {
command->awaitCompletion();
}
*not_null(event) = as_cl(&command->event());
if (event == NULL) {
command->release();
}
return CL_SUCCESS;
}
RUNTIME_ENTRY(cl_int, clEnqueueReadSsgFileAMD,
(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write,
size_t buffer_offset, size_t cb, cl_file_amd file, size_t file_offset,
cl_uint num_events_in_wait_list, const cl_event* event_wait_list, cl_event* event)) {
return EnqueueTransferBufferFromSsgFileAMD(CL_TRUE, command_queue, buffer, blocking_write,
buffer_offset, cb, file, file_offset,
num_events_in_wait_list, event_wait_list, event);
}
RUNTIME_EXIT
RUNTIME_ENTRY(cl_int, clEnqueueWriteSsgFileAMD,
(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write,
size_t buffer_offset, size_t cb, cl_file_amd file, size_t file_offset,
cl_uint num_events_in_wait_list, const cl_event* event_wait_list, cl_event* event)) {
return EnqueueTransferBufferFromSsgFileAMD(CL_FALSE, command_queue, buffer, blocking_write,
buffer_offset, cb, file, file_offset,
num_events_in_wait_list, event_wait_list, event);
}
RUNTIME_EXIT
-58
View File
@@ -1,58 +0,0 @@
/* Copyright (c) 2015 - 2021 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 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 __CL_LQDFLASH_AMD_H
#define __CL_LQDFLASH_AMD_H
#include "CL/cl_ext.h"
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
extern CL_API_ENTRY cl_file_amd CL_API_CALL
clCreateSsgFileObjectAMD(cl_context context, cl_file_flags_amd flags, const wchar_t* file_name,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL clGetSsgFileObjectInfoAMD(
cl_file_amd file, cl_file_info_amd param_name, size_t param_value_size, void* param_value,
size_t* param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL clRetainSsgFileObjectAMD(cl_file_amd file)
CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL clReleaseSsgFileObjectAMD(cl_file_amd file)
CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadSsgFileAMD(
cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t buffer_offset,
size_t cb, cl_file_amd file, size_t file_offset, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, cl_event* event) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteSsgFileAMD(
cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t buffer_offset,
size_t cb, cl_file_amd file, size_t file_offset, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, cl_event* event) CL_EXT_SUFFIX__VERSION_1_2;
#ifdef __cplusplus
} /*extern "C"*/
#endif /*__cplusplus*/
#endif
@@ -271,70 +271,6 @@ typedef CL_API_ENTRY cl_int
const cl_event * /*event_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
/**********************
* cl_amd_liquid_flash *
***********************/
#define cl_amd_liquid_flash 1
#define CL_COMMAND_READ_SSG_FILE_AMD 0x4083
#define CL_COMMAND_WRITE_SSG_FILE_AMD 0x4087
#define CL_INVALID_FILE_OBJECT_AMD 0x4084
typedef struct _cl_file_amd * cl_file_amd;
typedef cl_uint cl_file_flags_amd;
#define CL_FILE_READ_ONLY_AMD (1 << 0)
#define CL_FILE_WRITE_ONLY_AMD (1 << 1)
#define CL_FILE_READ_WRITE_AMD (1 << 2)
typedef cl_uint cl_file_info_amd;
#define CL_FILE_BLOCK_SIZE_AMD 0x4085
#define CL_FILE_SIZE_AMD 0x4086
typedef CL_API_ENTRY cl_file_amd
(CL_API_CALL * clCreateSsgFileObjectAMD_fn)(cl_context /*context*/,
cl_file_flags_amd /*flags*/,
const wchar_t * /*file_name*/,
cl_int * /*errcode_ret*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clGetSsgFileObjectInfoAMD_fn)(cl_file_amd /* file */,
cl_file_info_amd /* param_name */,
size_t /* param_value_size */,
void * /* param_value */,
size_t * /* param_value_size_ret */) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clRetainSsgFileObjectAMD_fn)( cl_file_amd /*file*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clReleaseSsgFileObjectAMD_fn)( cl_file_amd /*file*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clEnqueueReadSsgFileAMD_fn)(cl_command_queue /*command_queue*/,
cl_mem /*buffer*/,
cl_bool /*blocking_write*/,
size_t /*buffer_offset*/,
size_t /*cb*/,
cl_file_amd /*file*/,
size_t /*file_offset*/,
cl_uint /*num_events_in_wait_list*/,
const cl_event * /*event_wait_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clEnqueueWriteSsgFileAMD_fn)(cl_command_queue /*command_queue*/,
cl_mem /*buffer*/,
cl_bool /*blocking_read*/,
size_t /*buffer_offset*/,
size_t /*cb*/,
cl_file_amd /*file*/,
size_t /*file_offset*/,
cl_uint /*num_events_in_wait_list*/,
const cl_event * /*event_wait_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
/*************************
* cl_amd_copy_buffer_p2p *
**************************/
@@ -290,70 +290,6 @@ typedef CL_API_ENTRY cl_int
const cl_event * /*event_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
/**********************
* cl_amd_liquid_flash *
***********************/
#define cl_amd_liquid_flash 1
#define CL_COMMAND_READ_SSG_FILE_AMD 0x4083
#define CL_COMMAND_WRITE_SSG_FILE_AMD 0x4087
#define CL_INVALID_FILE_OBJECT_AMD 0x4084
typedef struct _cl_file_amd * cl_file_amd;
typedef cl_uint cl_file_flags_amd;
#define CL_FILE_READ_ONLY_AMD (1 << 0)
#define CL_FILE_WRITE_ONLY_AMD (1 << 1)
#define CL_FILE_READ_WRITE_AMD (1 << 2)
typedef cl_uint cl_file_info_amd;
#define CL_FILE_BLOCK_SIZE_AMD 0x4085
#define CL_FILE_SIZE_AMD 0x4086
typedef CL_API_ENTRY cl_file_amd
(CL_API_CALL * clCreateSsgFileObjectAMD_fn)(cl_context /*context*/,
cl_file_flags_amd /*flags*/,
const wchar_t * /*file_name*/,
cl_int * /*errcode_ret*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clGetSsgFileObjectInfoAMD_fn)(cl_file_amd /* file */,
cl_file_info_amd /* param_name */,
size_t /* param_value_size */,
void * /* param_value */,
size_t * /* param_value_size_ret */) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clRetainSsgFileObjectAMD_fn)( cl_file_amd /*file*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clReleaseSsgFileObjectAMD_fn)( cl_file_amd /*file*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clEnqueueReadSsgFileAMD_fn)(cl_command_queue /*command_queue*/,
cl_mem /*buffer*/,
cl_bool /*blocking_write*/,
size_t /*buffer_offset*/,
size_t /*cb*/,
cl_file_amd /*file*/,
size_t /*file_offset*/,
cl_uint /*num_events_in_wait_list*/,
const cl_event * /*event_wait_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clEnqueueWriteSsgFileAMD_fn)(cl_command_queue /*command_queue*/,
cl_mem /*buffer*/,
cl_bool /*blocking_read*/,
size_t /*buffer_offset*/,
size_t /*cb*/,
cl_file_amd /*file*/,
size_t /*file_offset*/,
cl_uint /*num_events_in_wait_list*/,
const cl_event * /*event_wait_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
/*************************
* cl_amd_copy_buffer_p2p *
**************************/
@@ -271,70 +271,6 @@ typedef CL_API_ENTRY cl_int
const cl_event * /*event_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
/**********************
* cl_amd_liquid_flash *
***********************/
#define cl_amd_liquid_flash 1
#define CL_COMMAND_READ_SSG_FILE_AMD 0x4083
#define CL_COMMAND_WRITE_SSG_FILE_AMD 0x4087
#define CL_INVALID_FILE_OBJECT_AMD 0x4084
typedef struct _cl_file_amd * cl_file_amd;
typedef cl_uint cl_file_flags_amd;
#define CL_FILE_READ_ONLY_AMD (1 << 0)
#define CL_FILE_WRITE_ONLY_AMD (1 << 1)
#define CL_FILE_READ_WRITE_AMD (1 << 2)
typedef cl_uint cl_file_info_amd;
#define CL_FILE_BLOCK_SIZE_AMD 0x4085
#define CL_FILE_SIZE_AMD 0x4086
typedef CL_API_ENTRY cl_file_amd
(CL_API_CALL * clCreateSsgFileObjectAMD_fn)(cl_context /*context*/,
cl_file_flags_amd /*flags*/,
const wchar_t * /*file_name*/,
cl_int * /*errcode_ret*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clGetSsgFileObjectInfoAMD_fn)(cl_file_amd /* file */,
cl_file_info_amd /* param_name */,
size_t /* param_value_size */,
void * /* param_value */,
size_t * /* param_value_size_ret */) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clRetainSsgFileObjectAMD_fn)( cl_file_amd /*file*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clReleaseSsgFileObjectAMD_fn)( cl_file_amd /*file*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clEnqueueReadSsgFileAMD_fn)(cl_command_queue /*command_queue*/,
cl_mem /*buffer*/,
cl_bool /*blocking_write*/,
size_t /*buffer_offset*/,
size_t /*cb*/,
cl_file_amd /*file*/,
size_t /*file_offset*/,
cl_uint /*num_events_in_wait_list*/,
const cl_event * /*event_wait_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clEnqueueWriteSsgFileAMD_fn)(cl_command_queue /*command_queue*/,
cl_mem /*buffer*/,
cl_bool /*blocking_read*/,
size_t /*buffer_offset*/,
size_t /*cb*/,
cl_file_amd /*file*/,
size_t /*file_offset*/,
cl_uint /*num_events_in_wait_list*/,
const cl_event * /*event_wait_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
/*************************
* cl_amd_copy_buffer_p2p *
**************************/
@@ -318,70 +318,6 @@ typedef CL_API_ENTRY cl_int
const cl_event * /*event_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
/**********************
* cl_amd_liquid_flash *
***********************/
#define cl_amd_liquid_flash 1
#define CL_COMMAND_READ_SSG_FILE_AMD 0x4083
#define CL_COMMAND_WRITE_SSG_FILE_AMD 0x4087
#define CL_INVALID_FILE_OBJECT_AMD 0x4084
typedef struct _cl_file_amd * cl_file_amd;
typedef cl_uint cl_file_flags_amd;
#define CL_FILE_READ_ONLY_AMD (1 << 0)
#define CL_FILE_WRITE_ONLY_AMD (1 << 1)
#define CL_FILE_READ_WRITE_AMD (1 << 2)
typedef cl_uint cl_file_info_amd;
#define CL_FILE_BLOCK_SIZE_AMD 0x4085
#define CL_FILE_SIZE_AMD 0x4086
typedef CL_API_ENTRY cl_file_amd
(CL_API_CALL * clCreateSsgFileObjectAMD_fn)(cl_context /*context*/,
cl_file_flags_amd /*flags*/,
const wchar_t * /*file_name*/,
cl_int * /*errcode_ret*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clGetSsgFileObjectInfoAMD_fn)(cl_file_amd /* file */,
cl_file_info_amd /* param_name */,
size_t /* param_value_size */,
void * /* param_value */,
size_t * /* param_value_size_ret */) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clRetainSsgFileObjectAMD_fn)( cl_file_amd /*file*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clReleaseSsgFileObjectAMD_fn)( cl_file_amd /*file*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clEnqueueReadSsgFileAMD_fn)(cl_command_queue /*command_queue*/,
cl_mem /*buffer*/,
cl_bool /*blocking_write*/,
size_t /*buffer_offset*/,
size_t /*cb*/,
cl_file_amd /*file*/,
size_t /*file_offset*/,
cl_uint /*num_events_in_wait_list*/,
const cl_event * /*event_wait_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int
(CL_API_CALL * clEnqueueWriteSsgFileAMD_fn)(cl_command_queue /*command_queue*/,
cl_mem /*buffer*/,
cl_bool /*blocking_read*/,
size_t /*buffer_offset*/,
size_t /*cb*/,
cl_file_amd /*file*/,
size_t /*file_offset*/,
cl_uint /*num_events_in_wait_list*/,
const cl_event * /*event_wait_list*/,
cl_event * /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
/*************************
* cl_amd_copy_buffer_p2p *
**************************/
@@ -20,7 +20,6 @@ set(TESTS
OCLKernelBinary
OCLLDS32K
OCLLinearFilter
OCLLiquidFlash
OCLMapCount
OCLMemDependency
OCLMemObjs
@@ -1,264 +0,0 @@
/* Copyright (c) 2010 - 2021 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 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. */
#include "OCLLiquidFlash.h"
#include <Timer.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <fstream>
#include <sstream>
#include "CL/cl.h"
const static size_t ChunkSize = 256 * 1024;
const static int NumSizes = 5;
const static int NumChunksArray[NumSizes] = {1, 4, 16, 32, 56};
const static size_t MaxSubTests = 4 * NumSizes;
const static char* BinFileName = "LiquidFlash.bin";
const static int NumIterArray[NumSizes] = {20, 15, 10, 10, 10};
const static int NumStagesArray[NumSizes] = {2, 2, 4, 4, 4};
OCLLiquidFlash::OCLLiquidFlash() {
#ifdef CL_VERSION_2_0
_numSubTests = MaxSubTests;
failed_ = false;
maxSize_ = 0;
direct_ = false;
amdFile_ = NULL;
#else
_numSubTests = 0;
failed_ = false;
maxSize_ = 0;
direct_ = false;
#endif
}
OCLLiquidFlash::~OCLLiquidFlash() {}
void OCLLiquidFlash::open(unsigned int test, char* units, double& conversion,
unsigned int deviceId) {
#ifdef CL_VERSION_2_0
failed_ = false;
OCLTestImp::open(test, units, conversion, deviceId);
CHECK_RESULT((error_ != CL_SUCCESS), "Error opening test");
testID_ = test;
char name[1024] = {0};
size_t size = 0;
_wrapper->clGetDeviceInfo(devices_[deviceId], CL_DEVICE_EXTENSIONS, 1024,
name, &size);
if (!strstr(name, "cl_amd_liquid_flash")) {
printf("Liquid flash extension is required for this test!\n");
failed_ = true;
return;
}
NumChunks = NumChunksArray[testID_ / 4];
NumIter = NumIterArray[testID_ / 4];
NumStages = NumStagesArray[testID_ / 4];
BufferSize = NumChunks * ChunkSize * sizeof(cl_uint);
direct_ = ((testID_ % 4) < 3) ? true : false;
createFile =
(clCreateSsgFileObjectAMD_fn)clGetExtensionFunctionAddressForPlatform(
platform_, "clCreateSsgFileObjectAMD");
retainFile =
(clRetainSsgFileObjectAMD_fn)clGetExtensionFunctionAddressForPlatform(
platform_, "clRetainSsgFileObjectAMD");
releaseFile =
(clReleaseSsgFileObjectAMD_fn)clGetExtensionFunctionAddressForPlatform(
platform_, "clReleaseSsgFileObjectAMD");
writeBufferFromFile =
(clEnqueueReadSsgFileAMD_fn)clGetExtensionFunctionAddressForPlatform(
platform_, "clEnqueueReadSsgFileAMD");
if (createFile == NULL || retainFile == NULL || releaseFile == NULL ||
writeBufferFromFile == NULL) {
testDescString = "Failed to initialize LiquidFlash extension!\n";
failed_ = true;
return;
}
size_t chunkSize = ChunkSize;
std::ofstream fs;
fs.open(BinFileName, std::fstream::binary);
if (fs.is_open()) {
// allocate memory for file content
cl_uint* buffer = new cl_uint[chunkSize];
for (cl_uint i = 0; i < chunkSize; ++i) {
buffer[i] = i;
}
for (int i = 0; i < NumChunks; ++i) {
fs.write(reinterpret_cast<char*>(buffer), chunkSize * sizeof(cl_uint));
}
delete[] buffer;
}
fs.close();
std::string str(BinFileName);
std::wstring wc(str.length(), L' ');
// Copy string to wstring.
std::copy(str.begin(), str.end(), wc.begin());
amdFile_ = createFile(context_, CL_FILE_READ_ONLY_AMD, wc.c_str(), &error_);
if (error_ != CL_SUCCESS) {
printf(
"Create file failed. Liquid flash support is required for this "
"test!\n");
failed_ = true;
return;
}
cl_mem buf = NULL;
if (direct_) {
cl_uint subTest = testID_ % 4;
cl_uint memFlags = (subTest == 0)
? CL_MEM_USE_PERSISTENT_MEM_AMD
: ((subTest == 1) ? CL_MEM_ALLOC_HOST_PTR : 0);
buf = _wrapper->clCreateBuffer(context_, CL_MEM_READ_ONLY | memFlags,
BufferSize, NULL, &error_);
CHECK_RESULT((error_ != CL_SUCCESS),
"clEnqueueWriteBufferFromFileAMD() failed");
} else {
for (int i = 0; i < NumStages; ++i) {
buf = _wrapper->clCreateBuffer(context_,
CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR,
BufferSize / NumStages, NULL, &error_);
CHECK_RESULT((error_ != CL_SUCCESS),
"clEnqueueWriteBufferFromFileAMD() failed");
buffers_.push_back(buf);
}
buf = _wrapper->clCreateBuffer(context_, CL_MEM_READ_WRITE, BufferSize,
NULL, &error_);
CHECK_RESULT((error_ != CL_SUCCESS),
"clEnqueueWriteBufferFromFileAMD() failed");
}
buffers_.push_back(buf);
#endif
}
void OCLLiquidFlash::run(void) {
#ifdef CL_VERSION_2_0
if (failed_) {
return;
}
size_t finalBuf = (direct_) ? 0 : NumStages;
cl_uint* buffer = new cl_uint[NumChunks * ChunkSize];
size_t iterSize = BufferSize / NumStages;
memset(buffer, 0, BufferSize);
if (direct_) {
error_ = _wrapper->clEnqueueWriteBuffer(cmdQueues_[_deviceId], buffers_[0],
CL_TRUE, 0, BufferSize, buffer, 0,
NULL, NULL);
CHECK_RESULT((error_ != CL_SUCCESS), "clEnqueueWriteBuffer() failed");
} else {
for (int i = 0; i < NumStages; ++i) {
error_ = _wrapper->clEnqueueWriteBuffer(cmdQueues_[_deviceId],
buffers_[i], CL_TRUE, 0, iterSize,
buffer, 0, NULL, NULL);
CHECK_RESULT((error_ != CL_SUCCESS), "clEnqueueWriteBuffer() failed");
}
error_ = _wrapper->clEnqueueWriteBuffer(cmdQueues_[_deviceId],
buffers_[finalBuf], CL_TRUE, 0,
BufferSize, buffer, 0, NULL, NULL);
CHECK_RESULT((error_ != CL_SUCCESS), "clEnqueueWriteBuffer() failed");
}
CPerfCounter timer;
double sec = 0.;
for (int i = 0; i < NumIter; ++i) {
timer.Reset();
timer.Start();
if (direct_) {
error_ = writeBufferFromFile(
cmdQueues_[_deviceId], buffers_[0], CL_FALSE, 0 /*buffer_offset*/,
BufferSize, amdFile_ /*file*/, 0 /*file_offset*/, 0, NULL, NULL);
CHECK_RESULT((error_ != CL_SUCCESS), "writeBufferFromFile() failed");
} else {
for (int i = 0; i < NumStages; ++i) {
error_ = writeBufferFromFile(
cmdQueues_[_deviceId], buffers_[i], CL_FALSE, 0 /*buffer_offset*/,
iterSize, amdFile_ /*file*/, iterSize * i /*file_offset*/, 0, NULL,
NULL);
CHECK_RESULT((error_ != CL_SUCCESS), "writeBufferFromFile() failed");
error_ = _wrapper->clEnqueueCopyBuffer(
cmdQueues_[_deviceId], buffers_[i], buffers_[NumStages], 0,
iterSize * i, iterSize, 0, NULL, NULL);
CHECK_RESULT((error_ != CL_SUCCESS), "CopyBuffer() failed");
_wrapper->clFlush(cmdQueues_[_deviceId]);
}
}
_wrapper->clFinish(cmdQueues_[_deviceId]);
timer.Stop();
double cur = timer.GetElapsedTime();
if (i == 0) {
sec = cur;
} else {
sec = std::min(cur, sec);
}
}
error_ = _wrapper->clEnqueueReadBuffer(cmdQueues_[_deviceId],
buffers_[finalBuf], CL_TRUE, 0,
BufferSize, buffer, 0, NULL, NULL);
CHECK_RESULT((error_ != CL_SUCCESS), "Validation failed!");
for (int c = 0; c < NumChunks; ++c) {
for (cl_uint i = 0; i < ChunkSize; ++i) {
if (buffer[c * ChunkSize + i] != i) {
CHECK_RESULT(false, "Validation failed!");
}
}
}
delete[] buffer;
static const char* MemTypeStr[] = {"Visible ", "Remote ", "Invisible",
"Staging"};
_perfInfo = (float)BufferSize / ((float)sec * 1024.f * 1024.f);
std::stringstream str;
str << "WriteBufferFromFile performance (";
str << BufferSize / (1024 * 1024);
str << " MB of " << MemTypeStr[testID_ % 4] << ") transfer speed (MB/s):";
testDescString = str.str();
#endif
}
unsigned int OCLLiquidFlash::close(void) {
#ifdef CL_VERSION_2_0
if (!failed_) {
if (amdFile_ != NULL) {
releaseFile(amdFile_);
}
if (remove(BinFileName) != 0) {
}
}
return OCLTestImp::close();
#else
return CL_SUCCESS;
#endif
}
@@ -1,57 +0,0 @@
/* Copyright (c) 2010 - 2021 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 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 _OCL_LIQUID_FLASH_H_
#define _OCL_LIQUID_FLASH_H_
#include "OCLTestImp.h"
class OCLLiquidFlash : public OCLTestImp {
public:
OCLLiquidFlash();
virtual ~OCLLiquidFlash();
public:
virtual void open(unsigned int test, char* units, double& conversion,
unsigned int deviceID);
virtual void run(void);
virtual unsigned int close(void);
private:
bool failed_;
unsigned int testID_;
cl_ulong maxSize_;
#ifdef CL_VERSION_2_0
cl_file_amd amdFile_;
#endif
bool direct_;
size_t BufferSize;
int NumChunks;
int NumIter;
int NumStages;
#ifdef CL_VERSION_2_0
clCreateSsgFileObjectAMD_fn createFile;
clRetainSsgFileObjectAMD_fn retainFile;
clReleaseSsgFileObjectAMD_fn releaseFile;
clEnqueueReadSsgFileAMD_fn writeBufferFromFile;
#endif
};
#endif // _OCL_LIQUID_FLASH_H_
@@ -53,4 +53,4 @@ class OCLP2PBuffer : public OCLTestImp {
#endif
};
#endif // _OCL_LIQUID_FLASH_H_
#endif // _OCL_P2P_BUFFER_H_
@@ -44,7 +44,6 @@
#include "OCLKernelBinary.h"
#include "OCLLDS32K.h"
#include "OCLLinearFilter.h"
#include "OCLLiquidFlash.h"
#include "OCLMapCount.h"
#include "OCLMemDependency.h"
#include "OCLMemObjs.h"
@@ -113,7 +112,6 @@ TestEntry TestList[] = {
TEST(OCLDynamicBLines),
TEST(OCLUnalignedCopy),
TEST(OCLBlitKernel),
TEST(OCLLiquidFlash),
TEST(OCLRTQueue),
TEST(OCLAsyncMap),
TEST(OCLPinnedMemory),