mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Updating files modified in 2018 only. Older files remain with old style copyright header Change-Id: Ic99f2e190ad74b4b7f2bd79dd7b9fa5fbe36ec92 Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
96 lines
3.2 KiB
C++
96 lines
3.2 KiB
C++
/*
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "cl_api_tests.h"
|
|
#include "runtime/command_queue/command_queue.h"
|
|
#include "runtime/context/context.h"
|
|
#include "runtime/device/device.h"
|
|
|
|
using namespace OCLRT;
|
|
|
|
typedef api_tests clEnqueueSVMUnmapTests;
|
|
|
|
namespace ULT {
|
|
|
|
TEST_F(clEnqueueSVMUnmapTests, invalidCommandQueue) {
|
|
auto retVal = clEnqueueSVMUnmap(
|
|
nullptr, // cl_command_queue command_queue
|
|
nullptr, // void *svm_ptr
|
|
0, // cl_uint num_events_in_wait_list
|
|
nullptr, // const cl_event *event_wait_list
|
|
nullptr // cl_event *event
|
|
);
|
|
EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retVal);
|
|
}
|
|
|
|
TEST_F(clEnqueueSVMUnmapTests, invalidValue) {
|
|
auto retVal = clEnqueueSVMUnmap(
|
|
pCommandQueue, // cl_command_queue command_queue
|
|
nullptr, // void *svm_ptr
|
|
0, // cl_uint num_events_in_wait_list
|
|
nullptr, // const cl_event *event_wait_list
|
|
nullptr // cl_event *event
|
|
);
|
|
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
|
}
|
|
|
|
TEST_F(clEnqueueSVMUnmapTests, invalidEventWaitList_EventWaitListIsNullAndNumEventsInWaitListIsGreaterThanZero) {
|
|
auto retVal = clEnqueueSVMUnmap(
|
|
pCommandQueue, // cl_command_queue command_queue
|
|
nullptr, // void *svm_ptr
|
|
1, // cl_uint num_events_in_wait_list
|
|
nullptr, // const cl_event *event_wait_list
|
|
nullptr // cl_event *event
|
|
);
|
|
EXPECT_EQ(CL_INVALID_EVENT_WAIT_LIST, retVal);
|
|
}
|
|
|
|
TEST_F(clEnqueueSVMUnmapTests, invalidEventWaitList_EventWaitListIsNotNullAndNumEventsInWaitListIsZero) {
|
|
UserEvent uEvent(pContext);
|
|
cl_event eventWaitList[] = {&uEvent};
|
|
auto retVal = clEnqueueSVMUnmap(
|
|
pCommandQueue, // cl_command_queue command_queue
|
|
nullptr, // void *svm_ptr
|
|
0, // cl_uint num_events_in_wait_list
|
|
eventWaitList, // const cl_event *event_wait_list
|
|
nullptr // cl_event *event
|
|
);
|
|
EXPECT_EQ(CL_INVALID_EVENT_WAIT_LIST, retVal);
|
|
}
|
|
|
|
TEST_F(clEnqueueSVMUnmapTests, success) {
|
|
const DeviceInfo &devInfo = pPlatform->getDevice(0)->getDeviceInfo();
|
|
if (devInfo.svmCapabilities != 0) {
|
|
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
|
EXPECT_NE(nullptr, ptrSvm);
|
|
|
|
auto retVal = clEnqueueSVMMap(
|
|
pCommandQueue, // cl_command_queue command_queue
|
|
CL_FALSE, // cl_bool blocking_map
|
|
CL_MAP_READ, // cl_map_flags map_flags
|
|
ptrSvm, // void *svm_ptr
|
|
256, // size_t size
|
|
0, // cl_uint num_events_in_wait_list
|
|
nullptr, // const cL_event *event_wait_list
|
|
nullptr // cl_event *event
|
|
);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
|
|
retVal = clEnqueueSVMUnmap(
|
|
pCommandQueue, // cl_command_queue command_queue
|
|
ptrSvm, // void *svm_ptr
|
|
0, // cl_uint num_events_in_wait_list
|
|
nullptr, // const cL_event *event_wait_list
|
|
nullptr // cl_event *event
|
|
);
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
|
|
clSVMFree(pContext, ptrSvm);
|
|
}
|
|
}
|
|
} // namespace ULT
|