From 79d4af28de00757ca66480e08352925b4bf552c6 Mon Sep 17 00:00:00 2001 From: Kamil Diedrich Date: Tue, 1 Dec 2020 10:27:10 +0100 Subject: [PATCH] Switch to c++17 Signed-off-by: Kamil Diedrich --- CMakeLists.txt | 4 +- .../program/kernel_info_from_patchtokens.cpp | 2 +- .../sku_info/sku_info_base_reference.h | 2 +- .../sku_info/sku_info_receiver_tests.cpp | 58 ++++++- .../sku_info/sku_info_transfer_tests.cpp | 4 +- .../device_binary_format/yaml/yaml_parser.h | 9 +- .../kernel_descriptor_from_patchtokens.cpp | 2 +- shared/source/sku_info/definitions/sku_info.h | 1 + shared/source/sku_info/sku_info_base.h | 149 ++++++++++-------- .../yaml/yaml_parser_tests.cpp | 9 +- 10 files changed, 162 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c953333f96..bd249e2f4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,8 +178,8 @@ if(NOT NEO_BINARY_DIR) set(NEO_BINARY_DIR ${CMAKE_BINARY_DIR}) endif() -# we use c++14 -set(CMAKE_CXX_STANDARD 14) +# we use c++17 +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # we force using response files diff --git a/opencl/source/program/kernel_info_from_patchtokens.cpp b/opencl/source/program/kernel_info_from_patchtokens.cpp index 1372927389..e162b03d5a 100644 --- a/opencl/source/program/kernel_info_from_patchtokens.cpp +++ b/opencl/source/program/kernel_info_from_patchtokens.cpp @@ -52,7 +52,7 @@ void populateKernelInfoArgMetadata(KernelInfo &dstKernelInfoArg, const SPatchKer if (nullptr == argTypeDelim) { argTypeDelim = argTypeFull.data() + argTypeFull.size(); } - metadataExtended->type = std::string(argTypeFull.data(), argTypeDelim).c_str(); + metadataExtended->type = std::string(static_cast(argTypeFull.data()), argTypeDelim).c_str(); metadataExtended->typeQualifiers = parseLimitedString(inlineData.typeQualifiers.begin(), inlineData.typeQualifiers.size()); ArgTypeTraits metadata = {}; diff --git a/opencl/test/unit_test/sku_info/sku_info_base_reference.h b/opencl/test/unit_test/sku_info/sku_info_base_reference.h index 739411ca3e..471363446a 100644 --- a/opencl/test/unit_test/sku_info/sku_info_base_reference.h +++ b/opencl/test/unit_test/sku_info/sku_info_base_reference.h @@ -33,8 +33,8 @@ struct SkuInfoBaseReference { refFtrTable.FtrTranslationTable = 1; refFtrTable.FtrUserModeTranslationTable = 1; - refFtrTable.FtrLLCBypass = 1; refFtrTable.FtrWddm2Svm = 1; + refFtrTable.FtrLLCBypass = 1; refFtrTable.FtrE2ECompression = 1; refFtrTable.FtrLinearCCS = 1; diff --git a/opencl/test/unit_test/sku_info/sku_info_receiver_tests.cpp b/opencl/test/unit_test/sku_info/sku_info_receiver_tests.cpp index 7573bde41a..bea16a4d4e 100644 --- a/opencl/test/unit_test/sku_info/sku_info_receiver_tests.cpp +++ b/opencl/test/unit_test/sku_info/sku_info_receiver_tests.cpp @@ -13,16 +13,72 @@ using namespace NEO; +inline bool operator==(const FeatureTable &lhs, const FeatureTable &rhs) { + return lhs.ftrBcsInfo == rhs.ftrBcsInfo && lhs.packed[0] == rhs.packed[0] && lhs.packed[1] == rhs.packed[1]; +} + TEST(SkuInfoReceiverTest, givenAdapterInfoWhenReceivingThenUpdateFtrTable) { FeatureTable refFeatureTable = {}; FeatureTable requestedFeatureTable = {}; ADAPTER_INFO adapterInfo = {}; memset(&adapterInfo.SkuTable, ~0, sizeof(adapterInfo.SkuTable)); + SkuInfoReceiver::receiveFtrTableFromAdapterInfo(&requestedFeatureTable, &adapterInfo); SkuInfoBaseReference::fillReferenceFtrToReceive(refFeatureTable); - EXPECT_TRUE(memcmp(&requestedFeatureTable, &refFeatureTable, sizeof(FeatureTable)) == 0); + EXPECT_TRUE(refFeatureTable == requestedFeatureTable); + + refFeatureTable.ftr3dMidBatchPreempt = false; + requestedFeatureTable.ftr3dMidBatchPreempt = true; + + EXPECT_FALSE(refFeatureTable == requestedFeatureTable); +} + +TEST(SkuInfoReceiverTest, givenFeatureTableWhenDifferentDataThenEqualityOperatorReturnsCorrectScore) { + FeatureTable refFeatureTable = {}; + FeatureTable requestedFeatureTable = {}; + + refFeatureTable.ftrBcsInfo = 1; + requestedFeatureTable.ftrBcsInfo = 0; + + EXPECT_FALSE(refFeatureTable == requestedFeatureTable); + + refFeatureTable.ftrBcsInfo = 0; + requestedFeatureTable.ftrBcsInfo = 1; + + EXPECT_FALSE(refFeatureTable == requestedFeatureTable); + + refFeatureTable.ftrBcsInfo = 1; + requestedFeatureTable.ftrBcsInfo = 1; + refFeatureTable.packed[0] = 1u; + requestedFeatureTable.packed[0] = 0; + + EXPECT_FALSE(refFeatureTable == requestedFeatureTable); + + refFeatureTable.packed[0] = 0; + requestedFeatureTable.packed[0] = 1; + + EXPECT_FALSE(refFeatureTable == requestedFeatureTable); + + refFeatureTable.packed[0] = 0; + requestedFeatureTable.packed[0] = 0; + refFeatureTable.packed[1] = 0; + requestedFeatureTable.packed[1] = 1; + + EXPECT_FALSE(refFeatureTable == requestedFeatureTable); + + refFeatureTable.packed[0] = 0; + requestedFeatureTable.packed[0] = 0; + refFeatureTable.packed[1] = 1; + requestedFeatureTable.packed[1] = 0; + + EXPECT_FALSE(refFeatureTable == requestedFeatureTable); + + refFeatureTable.packed[1] = 1; + requestedFeatureTable.packed[1] = 1; + + EXPECT_TRUE(refFeatureTable == requestedFeatureTable); } TEST(SkuInfoReceiverTest, givenAdapterInfoWhenReceivingThenUpdateWaTable) { diff --git a/opencl/test/unit_test/sku_info/sku_info_transfer_tests.cpp b/opencl/test/unit_test/sku_info/sku_info_transfer_tests.cpp index e15eef92c3..773abb1f1f 100644 --- a/opencl/test/unit_test/sku_info/sku_info_transfer_tests.cpp +++ b/opencl/test/unit_test/sku_info/sku_info_transfer_tests.cpp @@ -17,7 +17,9 @@ TEST(SkuInfoTransferTest, givenFeatureTableWhenFillingStructureForGmmThenCopyOnl _SKU_FEATURE_TABLE requestedFtrTable = {}; _SKU_FEATURE_TABLE refFtrTable = {}; FeatureTable featureTable; - memset(reinterpret_cast(&featureTable), 1, sizeof(FeatureTable)); + + featureTable.packed[0] = 0xFFFFFFFFFFFFFFFF; + featureTable.packed[1] = 0xFFFFFFFFFFFFFFFF; SkuInfoTransfer::transferFtrTableForGmm(&requestedFtrTable, &featureTable); SkuInfoBaseReference::fillReferenceFtrForTransfer(refFtrTable); diff --git a/shared/source/device_binary_format/yaml/yaml_parser.h b/shared/source/device_binary_format/yaml/yaml_parser.h index ead34fa705..e1284e001b 100644 --- a/shared/source/device_binary_format/yaml/yaml_parser.h +++ b/shared/source/device_binary_format/yaml/yaml_parser.h @@ -310,7 +310,14 @@ inline const Node *getLastChild(const Node &parent, const NodesCache &allNodes) return &allNodes[childId]; } -struct ConstSiblingsFwdIterator : std::iterator { +struct ConstSiblingsFwdIterator { + // iterator traits + using difference_type = long; + using value_type = long; + using pointer = const long *; + using reference = const long &; + using iterator_category = std::forward_iterator_tag; + ConstSiblingsFwdIterator(NodeId currId, const NodesCache *allNodes) : allNodes(allNodes), currId(currId) { } diff --git a/shared/source/kernel/kernel_descriptor_from_patchtokens.cpp b/shared/source/kernel/kernel_descriptor_from_patchtokens.cpp index 7529baf182..d78ed307fc 100644 --- a/shared/source/kernel/kernel_descriptor_from_patchtokens.cpp +++ b/shared/source/kernel/kernel_descriptor_from_patchtokens.cpp @@ -336,7 +336,7 @@ void populateArgMetadata(KernelDescriptor &dst, size_t argNum, const SPatchKerne if (nullptr == argTypeDelim) { argTypeDelim = argTypeFull.data() + argTypeFull.size(); } - metadataExtended->type = std::string(argTypeFull.data(), argTypeDelim).c_str(); + metadataExtended->type = std::string(static_cast(argTypeFull.data()), argTypeDelim).c_str(); metadataExtended->typeQualifiers = parseLimitedString(inlineData.typeQualifiers.begin(), inlineData.typeQualifiers.size()); ArgTypeTraits metadata = {}; diff --git a/shared/source/sku_info/definitions/sku_info.h b/shared/source/sku_info/definitions/sku_info.h index 752ed02ea3..0ca65c20b3 100644 --- a/shared/source/sku_info/definitions/sku_info.h +++ b/shared/source/sku_info/definitions/sku_info.h @@ -11,6 +11,7 @@ #include namespace NEO { + using BcsInfoMask = std::bitset<1>; struct FeatureTable : FeatureTableBase { diff --git a/shared/source/sku_info/sku_info_base.h b/shared/source/sku_info/sku_info_base.h index 8c710a9793..95e94fb4dc 100644 --- a/shared/source/sku_info/sku_info_base.h +++ b/shared/source/sku_info/sku_info_base.h @@ -7,92 +7,103 @@ #pragma once +#include + namespace NEO { struct FeatureTableBase { - bool ftrDesktop = false; - bool ftrChannelSwizzlingXOREnabled = false; + public: + FeatureTableBase() : packed{} { + ftrRcsNode = 1; + } + union { + struct { + bool ftrDesktop : 1; + bool ftrChannelSwizzlingXOREnabled : 1; - bool ftrGtBigDie = false; - bool ftrGtMediumDie = false; - bool ftrGtSmallDie = false; + bool ftrGtBigDie : 1; + bool ftrGtMediumDie : 1; + bool ftrGtSmallDie : 1; - bool ftrGT1 = false; - bool ftrGT1_5 = false; - bool ftrGT2 = false; - bool ftrGT2_5 = false; - bool ftrGT3 = false; - bool ftrGT4 = false; + bool ftrGT1 : 1; + bool ftrGT1_5 : 1; + bool ftrGT2 : 1; + bool ftrGT2_5 : 1; + bool ftrGT3 : 1; + bool ftrGT4 : 1; - bool ftrIVBM0M1Platform = false; - bool ftrSGTPVSKUStrapPresent = false; - bool ftrGTA = false; - bool ftrGTC = false; - bool ftrGTX = false; - bool ftr5Slice = false; + bool ftrIVBM0M1Platform : 1; + bool ftrSGTPVSKUStrapPresent : 1; + bool ftrGTA : 1; + bool ftrGTC : 1; + bool ftrGTX : 1; + bool ftr5Slice : 1; - bool ftrGpGpuMidBatchPreempt = false; - bool ftrGpGpuThreadGroupLevelPreempt = false; - bool ftrGpGpuMidThreadLevelPreempt = false; + bool ftrGpGpuMidBatchPreempt : 1; + bool ftrGpGpuThreadGroupLevelPreempt : 1; + bool ftrGpGpuMidThreadLevelPreempt : 1; - bool ftrIoMmuPageFaulting = false; - bool ftrWddm2Svm = false; - bool ftrPooledEuEnabled = false; + bool ftrIoMmuPageFaulting : 1; + bool ftrWddm2Svm : 1; + bool ftrPooledEuEnabled : 1; - bool ftrResourceStreamer = false; + bool ftrResourceStreamer : 1; - bool ftrPPGTT = false; - bool ftrSVM = false; - bool ftrEDram = false; - bool ftrL3IACoherency = false; - bool ftrIA32eGfxPTEs = false; + bool ftrPPGTT : 1; + bool ftrSVM : 1; + bool ftrEDram : 1; + bool ftrL3IACoherency : 1; + bool ftrIA32eGfxPTEs : 1; - bool ftr3dMidBatchPreempt = false; - bool ftr3dObjectLevelPreempt = false; - bool ftrPerCtxtPreemptionGranularityControl = false; + bool ftr3dMidBatchPreempt : 1; + bool ftr3dObjectLevelPreempt : 1; + bool ftrPerCtxtPreemptionGranularityControl : 1; - bool ftrTileY = false; - bool ftrDisplayYTiling = false; - bool ftrTranslationTable = false; - bool ftrUserModeTranslationTable = false; + bool ftrTileY : 1; + bool ftrDisplayYTiling : 1; + bool ftrTranslationTable : 1; + bool ftrUserModeTranslationTable : 1; - bool ftrEnableGuC = false; + bool ftrEnableGuC : 1; - bool ftrFbc = false; - bool ftrFbc2AddressTranslation = false; - bool ftrFbcBlitterTracking = false; - bool ftrFbcCpuTracking = false; + bool ftrFbc : 1; + bool ftrFbc2AddressTranslation : 1; + bool ftrFbcBlitterTracking : 1; + bool ftrFbcCpuTracking : 1; - bool ftrVcs2 = false; - bool ftrVEBOX = false; - bool ftrSingleVeboxSlice = false; - bool ftrULT = false; - bool ftrLCIA = false; - bool ftrGttCacheInvalidation = false; - bool ftrTileMappedResource = false; - bool ftrAstcHdr2D = false; - bool ftrAstcLdr2D = false; + bool ftrVcs2 : 1; + bool ftrVEBOX : 1; + bool ftrSingleVeboxSlice : 1; + bool ftrULT : 1; + bool ftrLCIA : 1; + bool ftrGttCacheInvalidation : 1; + bool ftrTileMappedResource : 1; + bool ftrAstcHdr2D : 1; + bool ftrAstcLdr2D : 1; - bool ftrStandardMipTailFormat = false; - bool ftrFrameBufferLLC = false; - bool ftrCrystalwell = false; - bool ftrLLCBypass = false; - bool ftrDisplayEngineS3d = false; - bool ftrVERing = false; - bool ftrWddm2GpuMmu = false; - bool ftrWddm2_1_64kbPages = false; - bool ftrWddmHwQueues = false; - bool ftrMemTypeMocsDeferPAT = false; + bool ftrStandardMipTailFormat : 1; + bool ftrFrameBufferLLC : 1; + bool ftrCrystalwell : 1; + bool ftrLLCBypass : 1; + bool ftrDisplayEngineS3d : 1; + bool ftrVERing : 1; + bool ftrWddm2GpuMmu : 1; + bool ftrWddm2_1_64kbPages : 1; + bool ftrWddmHwQueues : 1; + bool ftrMemTypeMocsDeferPAT : 1; - bool ftrKmdDaf = false; - bool ftrSimulationMode = false; + bool ftrKmdDaf : 1; + bool ftrSimulationMode : 1; - bool ftrE2ECompression = false; - bool ftrLinearCCS = false; - bool ftrCCSRing = false; - bool ftrCCSNode = false; - bool ftrRcsNode = true; - bool ftrLocalMemory = false; - bool ftrLocalMemoryAllows4KB = false; + bool ftrE2ECompression : 1; + bool ftrLinearCCS : 1; + bool ftrCCSRing : 1; + bool ftrCCSNode : 1; + bool ftrRcsNode : 1; + bool ftrLocalMemory : 1; + bool ftrLocalMemoryAllows4KB : 1; + }; + uint64_t packed[2]; + }; }; struct WorkaroundTableBase { diff --git a/shared/test/unit_test/device_binary_format/yaml/yaml_parser_tests.cpp b/shared/test/unit_test/device_binary_format/yaml/yaml_parser_tests.cpp index e1980af618..df98445afc 100644 --- a/shared/test/unit_test/device_binary_format/yaml/yaml_parser_tests.cpp +++ b/shared/test/unit_test/device_binary_format/yaml/yaml_parser_tests.cpp @@ -25,7 +25,14 @@ TEST(YamlIsWhitespace, GivenCharThenReturnsTrueOnlyWhenCharIsWhitespace) { } template -struct IteratorAsValue : std::iterator { +struct IteratorAsValue { + // iterator traits + using difference_type = long; + using value_type = long; + using pointer = const long *; + using reference = const long &; + using iterator_category = std::forward_iterator_tag; + IteratorAsValue(const T &v) : value(v) {} T operator*() const { return value; } IteratorAsValue &operator++() {