2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-02-19 17:43:37 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "runtime/command_queue/command_queue.h"
|
|
|
|
#include "runtime/context/context.h"
|
|
|
|
#include "runtime/device/device.h"
|
|
|
|
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "cl_api_tests.h"
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
typedef api_tests clEnqueueSVMUnmapTests;
|
|
|
|
|
|
|
|
namespace ULT {
|
|
|
|
|
2019-02-19 17:43:37 +08:00
|
|
|
TEST_F(clEnqueueSVMUnmapTests, GivenInvalidCommandQueueWhenUnmappingSvmThenInvalidCommandQueueErrorIsReturned) {
|
2017-12-21 07:45:38 +08:00
|
|
|
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
|
2018-06-13 03:54:39 +08:00
|
|
|
);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retVal);
|
|
|
|
}
|
|
|
|
|
2019-02-19 17:43:37 +08:00
|
|
|
TEST_F(clEnqueueSVMUnmapTests, GivenNullSvmPtrWhenUnmappingSvmThenInvalidValueErrorIsReturned) {
|
2017-12-21 07:45:38 +08:00
|
|
|
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
|
2018-06-13 03:54:39 +08:00
|
|
|
);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
|
|
|
}
|
|
|
|
|
2019-02-19 17:43:37 +08:00
|
|
|
TEST_F(clEnqueueSVMUnmapTests, GivenNullEventListAndNonZeroEventsWhenUnmappingSvmThenInvalidEventWaitListErrorIsReturned) {
|
2017-12-21 07:45:38 +08:00
|
|
|
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
|
2018-06-13 03:54:39 +08:00
|
|
|
);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(CL_INVALID_EVENT_WAIT_LIST, retVal);
|
|
|
|
}
|
|
|
|
|
2019-02-19 17:43:37 +08:00
|
|
|
TEST_F(clEnqueueSVMUnmapTests, GivenNonNullEventListAndZeroEventsWhenUnmappingSvmThenInvalidEventWaitListErrorIsReturned) {
|
2017-12-21 07:45:38 +08:00
|
|
|
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
|
2018-06-13 03:54:39 +08:00
|
|
|
);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(CL_INVALID_EVENT_WAIT_LIST, retVal);
|
|
|
|
}
|
|
|
|
|
2019-02-19 17:43:37 +08:00
|
|
|
TEST_F(clEnqueueSVMUnmapTests, GivenValidParametersWhenUnmappingSvmThenSuccessIsReturned) {
|
2017-12-21 07:45:38 +08:00
|
|
|
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
|
2018-06-13 03:54:39 +08:00
|
|
|
);
|
2017-12-21 07:45:38 +08:00
|
|
|
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
|
2018-06-13 03:54:39 +08:00
|
|
|
);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
|
|
|
|
|
|
clSVMFree(pContext, ptrSvm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace ULT
|