mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Implement r_pod_cast function
Related-To: NEO-6210 Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4286b3a55c
commit
9276f689f8
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/compiler_interface/compiler_cache.h"
|
||||
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/helpers/casts.h"
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/helpers/hash.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
@@ -36,9 +37,9 @@ const std::string CompilerCache::getCachedFileName(const HardwareInfo &hwInfo, c
|
||||
hash.update(&*internalOptions.begin(), internalOptions.size());
|
||||
|
||||
hash.update("----", 4);
|
||||
hash.update(reinterpret_cast<const char *>(&hwInfo.platform), sizeof(hwInfo.platform));
|
||||
hash.update(r_pod_cast<const char *>(&hwInfo.platform), sizeof(hwInfo.platform));
|
||||
hash.update("----", 4);
|
||||
hash.update(reinterpret_cast<const char *>(&hwInfo.featureTable.packed), sizeof(hwInfo.featureTable.packed));
|
||||
hash.update(r_pod_cast<const char *>(&hwInfo.featureTable.packed), sizeof(hwInfo.featureTable.packed));
|
||||
hash.update("----", 4);
|
||||
hash.update(reinterpret_cast<const char *>(&hwInfo.workaroundTable), sizeof(hwInfo.workaroundTable));
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ set(NEO_CORE_HELPERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cache_flush.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/casts.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/common_types.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config.cpp
|
||||
|
||||
28
shared/source/helpers/casts.h
Normal file
28
shared/source/helpers/casts.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace NEO {
|
||||
template <typename To, typename From>
|
||||
constexpr To r_pod_cast(From *f) {
|
||||
typedef typename std::remove_pointer<From>::type FromType;
|
||||
typedef typename std::remove_pointer<To>::type ToType;
|
||||
|
||||
static_assert(std::is_trivially_copyable<FromType>::value &&
|
||||
std::is_standard_layout<FromType>::value,
|
||||
"Original cast type is not POD");
|
||||
|
||||
static_assert(std::is_trivially_copyable<ToType>::value &&
|
||||
std::is_standard_layout<ToType>::value,
|
||||
"Target cast type is not POD");
|
||||
|
||||
return reinterpret_cast<To>(f);
|
||||
}
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user