2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-03-20 11:15:25 +01:00
|
|
|
#include "opencl/source/cl_device/cl_device.h"
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2018-06-26 10:51:01 +02:00
|
|
|
void PlatformFixture::SetUp() {
|
2018-06-26 16:15:48 +02:00
|
|
|
pPlatform = constructPlatform();
|
2017-12-21 00:45:38 +01:00
|
|
|
ASSERT_EQ(0u, pPlatform->getNumDevices());
|
|
|
|
|
|
|
|
// setup platform / context
|
2020-02-11 11:39:25 +01:00
|
|
|
bool isInitialized = initPlatform();
|
2017-12-21 00:45:38 +01:00
|
|
|
ASSERT_EQ(true, isInitialized);
|
|
|
|
|
|
|
|
num_devices = static_cast<cl_uint>(pPlatform->getNumDevices());
|
|
|
|
ASSERT_GT(num_devices, 0u);
|
|
|
|
|
2020-01-14 14:32:11 +01:00
|
|
|
auto allDev = pPlatform->getClDevices();
|
2017-12-21 00:45:38 +01:00
|
|
|
ASSERT_NE(nullptr, allDev);
|
|
|
|
|
|
|
|
devices = new cl_device_id[num_devices];
|
|
|
|
for (cl_uint deviceOrdinal = 0; deviceOrdinal < num_devices; ++deviceOrdinal) {
|
|
|
|
auto device = allDev[deviceOrdinal];
|
|
|
|
ASSERT_NE(nullptr, device);
|
|
|
|
devices[deviceOrdinal] = device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformFixture::TearDown() {
|
2020-09-01 12:38:50 +02:00
|
|
|
platformsImpl->clear();
|
2017-12-21 00:45:38 +01:00
|
|
|
delete[] devices;
|
|
|
|
}
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|