Create platformsImpl when needed

Change-Id: Ie89356761fc39910c765066d40cd363c93002692
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2020-09-04 11:22:19 +02:00 committed by sys_ocldev
parent 38ecb25ee6
commit 48c084ca32
5 changed files with 11 additions and 4 deletions

View File

@ -8,6 +8,9 @@
#include "opencl/source/platform/platform.h"
namespace NEO {
void __attribute__((constructor)) platformsConstructor() {
platformsImpl = new std::vector<std::unique_ptr<Platform>>;
}
void __attribute__((destructor)) platformsDestructor() {
delete platformsImpl;
platformsImpl = nullptr;

View File

@ -7,12 +7,14 @@
#include "opencl/source/platform/platform.h"
namespace NEO {
using namespace NEO;
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if (fdwReason == DLL_PROCESS_DETACH) {
delete platformsImpl;
}
if (fdwReason == DLL_PROCESS_ATTACH) {
platformsImpl = new std::vector<std::unique_ptr<Platform>>;
}
return TRUE;
}
} // namespace NEO

View File

@ -37,7 +37,7 @@
#include <map>
namespace NEO {
std::vector<std::unique_ptr<Platform>> *platformsImpl = new std::vector<std::unique_ptr<Platform>>;
std::vector<std::unique_ptr<Platform>> *platformsImpl = nullptr;
Platform::Platform(ExecutionEnvironment &executionEnvironmentIn) : executionEnvironment(executionEnvironmentIn) {
clDevices.reserve(4);

View File

@ -72,6 +72,7 @@ extern std::string lastTest;
bool generateRandomInput = false;
void applyWorkarounds() {
platformsImpl = new std::vector<std::unique_ptr<Platform>>;
platformsImpl->reserve(1);
{
std::ofstream f;
@ -152,6 +153,7 @@ void initializeTestHelpers() {
void cleanTestHelpers() {
GlobalMockSipProgram::shutDownSipProgram();
delete platformsImpl;
}
std::string getHardwarePrefix() {
@ -440,6 +442,5 @@ int main(int argc, char **argv) {
retVal = RUN_ALL_TESTS();
cleanTestHelpers();
delete platformsImpl;
return retVal;
}

View File

@ -74,6 +74,7 @@ extern std::string lastTest;
bool generateRandomInput = false;
void applyWorkarounds() {
platformsImpl = new std::vector<std::unique_ptr<Platform>>;
platformsImpl->reserve(1);
{
std::ofstream f;