mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +08:00
Reduce creating files when running ocloc tests
Add a new listener to track created files Related-To: NEO-7126 Co-authored-by: Artur Harasimiuk <artur.harasimiuk@intel.com> Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5206fd1b9a
commit
10c12bb3a7
@@ -55,6 +55,7 @@ set(NEO_CORE_HELPERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extendable_enum.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/file_io.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/file_io_load.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/file_io.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/flat_batch_buffer_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/flat_batch_buffer_helper.cpp
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -13,41 +13,6 @@
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
|
||||
std::unique_ptr<char[]> loadDataFromFile(
|
||||
const char *filename,
|
||||
size_t &retSize) {
|
||||
FILE *fp = nullptr;
|
||||
size_t nsize = 0;
|
||||
std::unique_ptr<char[]> ret;
|
||||
|
||||
DEBUG_BREAK_IF(nullptr == filename);
|
||||
// Open the file
|
||||
fopen_s(&fp, filename, "rb");
|
||||
if (fp) {
|
||||
// Allocate a buffer for the file contents
|
||||
fseek(fp, 0, SEEK_END);
|
||||
nsize = (size_t)ftell(fp);
|
||||
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
ret.reset(new (std::nothrow) char[nsize + 1]);
|
||||
|
||||
if (ret) {
|
||||
// we initialize to all zeroes before reading in data
|
||||
memset(ret.get(), 0x00, nsize + 1);
|
||||
[[maybe_unused]] auto read = fread(ret.get(), sizeof(unsigned char), nsize, fp);
|
||||
DEBUG_BREAK_IF(read != nsize);
|
||||
} else {
|
||||
nsize = 0;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
retSize = nsize;
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t writeDataToFile(
|
||||
const char *filename,
|
||||
const void *pData,
|
||||
|
||||
49
shared/source/helpers/file_io_load.cpp
Normal file
49
shared/source/helpers/file_io_load.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/helpers/stdio.h"
|
||||
|
||||
#include "file_io.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
|
||||
std::unique_ptr<char[]> loadDataFromFile(
|
||||
const char *filename,
|
||||
size_t &retSize) {
|
||||
FILE *fp = nullptr;
|
||||
size_t nsize = 0;
|
||||
std::unique_ptr<char[]> ret;
|
||||
|
||||
DEBUG_BREAK_IF(nullptr == filename);
|
||||
// Open the file
|
||||
fopen_s(&fp, filename, "rb");
|
||||
if (fp) {
|
||||
// Allocate a buffer for the file contents
|
||||
fseek(fp, 0, SEEK_END);
|
||||
nsize = static_cast<size_t>(ftell(fp));
|
||||
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
ret.reset(new (std::nothrow) char[nsize + 1]);
|
||||
|
||||
if (ret) {
|
||||
// we initialize to all zeroes before reading in data
|
||||
memset(ret.get(), 0x00, nsize + 1);
|
||||
[[maybe_unused]] auto read = fread(ret.get(), sizeof(unsigned char), nsize, fp);
|
||||
DEBUG_BREAK_IF(read != nsize);
|
||||
} else {
|
||||
nsize = 0;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
retSize = nsize;
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user