mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Include files are now grouped and sorted in following order: 1. Header file of the class the current file implements 2. Project files 3. Third party files 4. Standard library Change-Id: If31af05652184169f7fee1d7ad08f1b2ed602cf0 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
/*
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/context/context.h"
|
|
|
|
#include "cl_api_tests.h"
|
|
|
|
using namespace OCLRT;
|
|
|
|
typedef api_tests clRetainMemObjectTests;
|
|
|
|
namespace ULT {
|
|
TEST_F(clRetainMemObjectTests, returnsSuccess) {
|
|
unsigned char *hostMem = nullptr;
|
|
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
|
|
static const unsigned int bufferSize = 16;
|
|
cl_mem buffer = nullptr;
|
|
cl_int retVal;
|
|
cl_uint theRef;
|
|
|
|
hostMem = new unsigned char[bufferSize];
|
|
memset(hostMem, 0xaa, bufferSize);
|
|
|
|
buffer = clCreateBuffer(
|
|
pContext,
|
|
flags,
|
|
bufferSize,
|
|
hostMem,
|
|
&retVal);
|
|
|
|
ASSERT_EQ(CL_SUCCESS, retVal);
|
|
EXPECT_NE(nullptr, buffer);
|
|
|
|
retVal = clRetainMemObject(buffer);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
|
|
retVal = clGetMemObjectInfo(buffer, CL_MEM_REFERENCE_COUNT,
|
|
sizeof(cl_uint), &theRef, NULL);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
EXPECT_EQ(2u, theRef);
|
|
|
|
retVal = clReleaseMemObject(buffer);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
|
|
retVal = clGetMemObjectInfo(buffer, CL_MEM_REFERENCE_COUNT,
|
|
sizeof(cl_uint), &theRef, NULL);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
EXPECT_EQ(1u, theRef);
|
|
|
|
retVal = clReleaseMemObject(buffer);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
|
|
delete[] hostMem;
|
|
}
|
|
} // namespace ULT
|