SWDEV-508742 - Make clCreatePipe spec compliant (#80)
[ROCm/clr commit: 7698d799ce]
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c04355bbe3
Коммит
dc39d67017
@@ -36,10 +36,9 @@
|
||||
*
|
||||
* \param flags is a bit-field that is used to specify allocation and usage
|
||||
* information such as the memory arena that should be used to allocate the pipe
|
||||
* object and how it will be used. Only CL_MEM_READ_ONLY, CL_MEM_WRITE_ONLY,
|
||||
* CL_MEM_READ_WRITE and CL_MEM_HOST_NO_ACCESS can be specified when creating a
|
||||
* pipe object. If value specified for flags is 0, the default is used which is
|
||||
* CL_MEM_READ_WRITE.
|
||||
* object and how it will be used. Only CL_MEM_READ_WRITE and CL_MEM_HOST_NO_ACCESS
|
||||
* can be specified when creating a pipe object. If value specified for flags is 0,
|
||||
* the default is used which is CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS.
|
||||
*
|
||||
* \param pipe_packet_size is the size in bytes of a pipe packet.
|
||||
*
|
||||
@@ -71,7 +70,7 @@
|
||||
* - CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required
|
||||
* by the OpenCL implementation on the host.
|
||||
*
|
||||
* \version 2.0r19
|
||||
* \version 2.0r29
|
||||
*/
|
||||
RUNTIME_ENTRY_RET(cl_mem, clCreatePipe,
|
||||
(cl_context context, cl_mem_flags flags, cl_uint pipe_packet_size,
|
||||
@@ -79,19 +78,22 @@ RUNTIME_ENTRY_RET(cl_mem, clCreatePipe,
|
||||
cl_int* errcode_ret)) {
|
||||
if (!is_valid(context)) {
|
||||
*not_null(errcode_ret) = CL_INVALID_CONTEXT;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const cl_mem_flags validFlags = (CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS);
|
||||
|
||||
if (flags == 0) {
|
||||
flags = validFlags;
|
||||
}
|
||||
|
||||
// check flags for validity
|
||||
cl_bitfield temp =
|
||||
flags & (CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | CL_MEM_HOST_NO_ACCESS);
|
||||
cl_bitfield temp = flags & ~validFlags;
|
||||
|
||||
if (temp &&
|
||||
!(CL_MEM_READ_WRITE == temp || CL_MEM_WRITE_ONLY == temp || CL_MEM_READ_ONLY == temp ||
|
||||
CL_MEM_HOST_NO_ACCESS == temp)) {
|
||||
if (temp) {
|
||||
*not_null(errcode_ret) = CL_INVALID_VALUE;
|
||||
LogWarning("invalid parameter \"flags\"");
|
||||
return (cl_mem)0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t size = sizeof(struct clk_pipe_t) + pipe_packet_size * pipe_max_packets;
|
||||
@@ -109,7 +111,7 @@ RUNTIME_ENTRY_RET(cl_mem, clCreatePipe,
|
||||
if (pipe_packet_size == 0 || pipe_max_packets == 0 || !sizePass) {
|
||||
*not_null(errcode_ret) = CL_INVALID_PIPE_SIZE;
|
||||
LogWarning("invalid parameter \"size = 0 or size > CL_DEVICE_PIPE_MAX_PACKET_SIZE\"");
|
||||
return (cl_mem)0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
amd::Context& amdContext = *as_amd(context);
|
||||
@@ -117,13 +119,13 @@ RUNTIME_ENTRY_RET(cl_mem, clCreatePipe,
|
||||
amd::Pipe(amdContext, flags, size, (size_t)pipe_packet_size, (size_t)pipe_max_packets);
|
||||
if (mem == NULL) {
|
||||
*not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY;
|
||||
return (cl_mem)0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!mem->create()) {
|
||||
*not_null(errcode_ret) = CL_MEM_OBJECT_ALLOCATION_FAILURE;
|
||||
mem->release();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*not_null(errcode_ret) = CL_SUCCESS;
|
||||
|
||||
@@ -41,6 +41,7 @@ set(TESTS
|
||||
OCLSVM
|
||||
OCLThreadTrace
|
||||
OCLUnalignedCopy
|
||||
OCLCreatePipe
|
||||
)
|
||||
|
||||
add_library(oclruntime SHARED
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/* Copyright (c) 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 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 "OCLCreatePipe.h"
|
||||
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
OCLCreatePipe::OCLCreatePipe() { _numSubTests = 1; }
|
||||
|
||||
OCLCreatePipe::~OCLCreatePipe() {}
|
||||
|
||||
void OCLCreatePipe::open(unsigned int test,
|
||||
char *units,
|
||||
double &conversion,
|
||||
unsigned int deviceId) {
|
||||
_deviceId = deviceId;
|
||||
}
|
||||
|
||||
void OCLCreatePipe::run(void) {
|
||||
std::vector<cl_device_id> devices(_deviceId + 1, nullptr);
|
||||
cl_platform_id platform = nullptr;
|
||||
cl_context context = nullptr;
|
||||
cl_int err = 0;
|
||||
|
||||
err = _wrapper->clGetPlatformIDs(1, &platform, nullptr);
|
||||
CHECK_RESULT(err, "clGetPlatformIDs failed");
|
||||
|
||||
err = _wrapper->clGetDeviceIDs(platform, CL_DEVICE_TYPE_DEFAULT,
|
||||
devices.size(), devices.data(), nullptr);
|
||||
CHECK_RESULT(err, "clGetDeviceIDs failed");
|
||||
|
||||
context = _wrapper->clCreateContext(nullptr, 1, &devices[_deviceId],
|
||||
nullptr, nullptr, &err);
|
||||
CHECK_RESULT(err, "clCreateContext failed");
|
||||
|
||||
constexpr std::array<cl_mem_flags, 3> valid_flags = {
|
||||
CL_MEM_READ_WRITE,
|
||||
CL_MEM_HOST_NO_ACCESS,
|
||||
|
||||
CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS,
|
||||
};
|
||||
|
||||
constexpr cl_uint pipe_packet_size = sizeof(int);
|
||||
constexpr cl_uint pipe_max_packets = 16;
|
||||
|
||||
for (cl_mem_flags flags : valid_flags) {
|
||||
cl_mem pipe = nullptr;
|
||||
|
||||
pipe = _wrapper->clCreatePipe(context, flags, pipe_packet_size,
|
||||
pipe_max_packets, nullptr, &err);
|
||||
|
||||
CHECK_RESULT(err, "clCreatePipe failed with flag %lu", flags);
|
||||
|
||||
if (!pipe) {
|
||||
break;
|
||||
}
|
||||
|
||||
err = _wrapper->clReleaseMemObject(pipe);
|
||||
CHECK_RESULT(err, "clReleaseMemObject failed");
|
||||
|
||||
if (err) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (err) {
|
||||
err = _wrapper->clReleaseContext(context);
|
||||
CHECK_RESULT(err, "clReleaseContext failed");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr std::array<cl_mem_flags, 5> invalid_flags = {
|
||||
CL_MEM_READ_ONLY,
|
||||
CL_MEM_WRITE_ONLY,
|
||||
|
||||
CL_MEM_READ_ONLY | CL_MEM_WRITE_ONLY,
|
||||
|
||||
0,
|
||||
~0UL,
|
||||
};
|
||||
|
||||
for (cl_mem_flags flags : valid_flags) {
|
||||
cl_mem pipe = nullptr;
|
||||
|
||||
pipe = _wrapper->clCreatePipe(context, flags, pipe_packet_size,
|
||||
pipe_max_packets, nullptr, &err);
|
||||
|
||||
CHECK_RESULT(err, "clCreatePipe passed when it shouldn't with flag %lu",
|
||||
flags);
|
||||
|
||||
if (err) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
err = _wrapper->clReleaseContext(context);
|
||||
CHECK_RESULT(err, "clReleaseContext failed");
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/* Copyright (c) 2010 - 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 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_OCLCreatePipe_H_
|
||||
#define _OCL_OCLCreatePipe_H_
|
||||
|
||||
#include "OCLTestImp.h"
|
||||
|
||||
class OCLCreatePipe : public OCLTestImp {
|
||||
public:
|
||||
OCLCreatePipe();
|
||||
virtual ~OCLCreatePipe();
|
||||
|
||||
public:
|
||||
virtual void open(unsigned int test, char* units, double& conversion,
|
||||
unsigned int deviceID);
|
||||
virtual void run(void);
|
||||
};
|
||||
|
||||
#endif // _OCL_OCLCreatePipe_H_
|
||||
@@ -65,6 +65,7 @@
|
||||
#include "OCLStablePState.h"
|
||||
#include "OCLThreadTrace.h"
|
||||
#include "OCLUnalignedCopy.h"
|
||||
#include "OCLCreatePipe.h"
|
||||
|
||||
//
|
||||
// Helper macro for adding tests
|
||||
@@ -118,6 +119,11 @@ TestEntry TestList[] = {
|
||||
TEST(OCLReadWriteImage),
|
||||
TEST(OCLStablePState),
|
||||
TEST(OCLP2PBuffer),
|
||||
|
||||
// Disabled until new Windows driver release that contains the
|
||||
// clCreatePipe changes
|
||||
// TEST(OCLCreatePipe),
|
||||
|
||||
// Failures in Linux. IOL doesn't support tiling aperture and Cypress linear
|
||||
// image writes TEST(OCLPersistent),
|
||||
};
|
||||
|
||||
Ссылка в новой задаче
Block a user