mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Ocloc compile: support gen families exposed in help
fix typo in method name Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
85a18d4dc9
commit
5a5ad64f5d
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "environment.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "hw_cmds.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -43,6 +44,26 @@ TEST(OclocApiTests, WhenGoodArgsAreGivenThenSuccessIsReturned) {
|
||||
EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4]));
|
||||
}
|
||||
|
||||
TEST(OclocApiTests, WhenGoodFamilyNameIsProvidedThenSuccessIsReturned) {
|
||||
const char *argv[] = {
|
||||
"ocloc",
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
NEO::familyName[NEO::DEFAULT_PLATFORM::hwInfo.platform.eRenderCoreFamily]};
|
||||
unsigned int argc = sizeof(argv) / sizeof(const char *);
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
int retVal = oclocInvoke(argc, argv,
|
||||
0, nullptr, nullptr, nullptr,
|
||||
0, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
||||
EXPECT_EQ(retVal, NEO::SUCCESS);
|
||||
EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4]));
|
||||
}
|
||||
|
||||
TEST(OclocApiTests, WhenArgsWithMissingFileAreGivenThenErrorMessageIsProduced) {
|
||||
const char *argv[] = {
|
||||
"ocloc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -29,7 +29,7 @@ bool requestedFatBinary(const std::vector<std::string> &args) {
|
||||
const bool hasMoreArgs = (argIndex + 1 < args.size());
|
||||
if ((ConstStringRef("-device") == currArg) && hasMoreArgs) {
|
||||
ConstStringRef deviceArg(args[argIndex + 1]);
|
||||
return deviceArg.contains("*") || deviceArg.contains("-") || deviceArg.contains(",") || deviceArg.contains("gen");
|
||||
return deviceArg.contains("*") || deviceArg.contains("-") || deviceArg.contains(",") || deviceArg.containsCaseInsensitive("gen");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -112,7 +112,7 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
|
||||
|
||||
if (range.size() == 1) {
|
||||
// open range , from-max or min-to
|
||||
if (range[0].contains("gen")) {
|
||||
if (range[0].containsCaseInsensitive("gen")) {
|
||||
auto coreIdList = asGfxCoreIdList(range[0]);
|
||||
if (coreIdList.empty()) {
|
||||
argHelper->printf("Unknown device : %s\n", set.str().c_str());
|
||||
@@ -197,7 +197,7 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
|
||||
requestedPlatforms.insert(requestedPlatforms.end(), from, to);
|
||||
}
|
||||
}
|
||||
} else if (set.contains("gen")) {
|
||||
} else if (set.containsCaseInsensitive("gen")) {
|
||||
if (set.size() == genArg.size()) {
|
||||
argHelper->printf("Invalid gen-based device : %s - gen should be followed by a number\n", set.str().c_str());
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -595,7 +595,7 @@ inline bool YamlParser::readValueChecked<bool>(const Node &node, bool &outValue)
|
||||
case 1:
|
||||
return true;
|
||||
case 3:
|
||||
return equalsCaseInsesitive(ConstStringRef("es"), ConstStringRef(token.cstrref().begin() + 1, 2));
|
||||
return equalsCaseInsensitive(ConstStringRef("es"), ConstStringRef(token.cstrref().begin() + 1, 2));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -618,7 +618,7 @@ inline bool YamlParser::readValueChecked<bool>(const Node &node, bool &outValue)
|
||||
if (token.len != 4) {
|
||||
return false;
|
||||
}
|
||||
return equalsCaseInsesitive(ConstStringRef("rue"), ConstStringRef(token.cstrref().begin() + 1, 3));
|
||||
return equalsCaseInsensitive(ConstStringRef("rue"), ConstStringRef(token.cstrref().begin() + 1, 3));
|
||||
}
|
||||
case 'f':
|
||||
case 'F': {
|
||||
@@ -626,7 +626,7 @@ inline bool YamlParser::readValueChecked<bool>(const Node &node, bool &outValue)
|
||||
if (token.len != 5) {
|
||||
return false;
|
||||
}
|
||||
return equalsCaseInsesitive(ConstStringRef("alse"), ConstStringRef(token.cstrref().begin() + 1, 4));
|
||||
return equalsCaseInsensitive(ConstStringRef("alse"), ConstStringRef(token.cstrref().begin() + 1, 4));
|
||||
}
|
||||
case 'o':
|
||||
case 'O': {
|
||||
@@ -638,7 +638,7 @@ inline bool YamlParser::readValueChecked<bool>(const Node &node, bool &outValue)
|
||||
return ((token.cstrref()[1] == 'n') | (token.cstrref()[1] == 'N'));
|
||||
case 3:
|
||||
outValue = false;
|
||||
return equalsCaseInsesitive(ConstStringRef("ff"), ConstStringRef(token.cstrref().begin() + 1, 2));
|
||||
return equalsCaseInsensitive(ConstStringRef("ff"), ConstStringRef(token.cstrref().begin() + 1, 2));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -137,6 +137,24 @@ class ConstStringRef {
|
||||
return false;
|
||||
}
|
||||
|
||||
constexpr bool containsCaseInsensitive(const char *subString) const noexcept {
|
||||
const char *findBeg = ptr;
|
||||
const char *findEnd = ptr + len;
|
||||
while (findBeg != findEnd) {
|
||||
const char *lhs = findBeg;
|
||||
const char *rhs = subString;
|
||||
while ((lhs < findEnd) && (std::tolower(*lhs) == std::tolower(*rhs)) && ('\0' != *rhs)) {
|
||||
++lhs;
|
||||
++rhs;
|
||||
}
|
||||
if ('\0' == *rhs) {
|
||||
return true;
|
||||
}
|
||||
++findBeg;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
constexpr bool startsWith(const char *subString) const noexcept {
|
||||
const char *findEnd = ptr + len;
|
||||
const char *lhs = ptr;
|
||||
@@ -207,7 +225,7 @@ constexpr bool operator!=(const char *lhs, const ConstStringRef &rhs) {
|
||||
return false == equals(rhs, lhs);
|
||||
}
|
||||
|
||||
constexpr bool equalsCaseInsesitive(const ConstStringRef &lhs, const ConstStringRef &rhs) {
|
||||
constexpr bool equalsCaseInsensitive(const ConstStringRef &lhs, const ConstStringRef &rhs) {
|
||||
if (lhs.size() != rhs.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -115,6 +115,28 @@ TEST(ConstStringRef, WhenCopyAsignedThenIdenticalAsOrigin) {
|
||||
EXPECT_EQ(a, b);
|
||||
}
|
||||
|
||||
TEST(ConstStringRef, WhenCheckingForInclusionCaseInsensitivelyThenDoesNotReadOutOfBounds) {
|
||||
static constexpr ConstStringRef str1("Text", 2);
|
||||
ConstStringRef substr1("tex");
|
||||
EXPECT_FALSE(str1.containsCaseInsensitive(substr1.data()));
|
||||
|
||||
static constexpr ConstStringRef str2("AabAac");
|
||||
ConstStringRef substr2("aac");
|
||||
EXPECT_TRUE(str2.containsCaseInsensitive(substr2.data()));
|
||||
|
||||
static constexpr ConstStringRef str3("AabAac");
|
||||
ConstStringRef substr3("aacd");
|
||||
EXPECT_FALSE(str3.containsCaseInsensitive(substr3.data()));
|
||||
}
|
||||
|
||||
TEST(ConstStringRef, GivenConstStringRefWithDifferentCasesWhenCheckingIfOneContainsTheOtherOneCaseInsensitivelyThenTrueIsReturned) {
|
||||
static constexpr ConstStringRef str1("TexT");
|
||||
static constexpr ConstStringRef str2("tEXt");
|
||||
|
||||
EXPECT_FALSE(str1.contains(str2.data()));
|
||||
EXPECT_TRUE(str1.containsCaseInsensitive(str2.data()));
|
||||
}
|
||||
|
||||
TEST(ConstStringRef, WhenCheckingForInclusionThenDoesNotReadOutOfBounds) {
|
||||
static constexpr ConstStringRef str1("Text", 2);
|
||||
ConstStringRef substr1("Tex");
|
||||
@@ -189,19 +211,19 @@ TEST(ConstStringRefTruncated, GivenNegativeLengthThenCountFromRight) {
|
||||
TEST(ConstStringRefEqualsCaseInsesitive, WhenSizesDifferReturnFalse) {
|
||||
ConstStringRef lhs = ConstStringRef::fromArray("\0");
|
||||
ConstStringRef rhs = ConstStringRef::fromArray("\0\0");
|
||||
EXPECT_FALSE(equalsCaseInsesitive(lhs, rhs));
|
||||
EXPECT_FALSE(equalsCaseInsensitive(lhs, rhs));
|
||||
}
|
||||
|
||||
TEST(ConstStringRefEqualsCaseInsesitive, WhenStringsDontMatchThenReturnFalse) {
|
||||
EXPECT_FALSE(equalsCaseInsesitive(ConstStringRef("abc"), ConstStringRef("abd")));
|
||||
EXPECT_FALSE(equalsCaseInsensitive(ConstStringRef("abc"), ConstStringRef("abd")));
|
||||
}
|
||||
|
||||
TEST(ConstStringRefEqualsCaseInsesitive, WhenStringsIdenticalThenReturnTrue) {
|
||||
EXPECT_TRUE(equalsCaseInsesitive(ConstStringRef("abc"), ConstStringRef("abc")));
|
||||
EXPECT_TRUE(equalsCaseInsensitive(ConstStringRef("abc"), ConstStringRef("abc")));
|
||||
}
|
||||
|
||||
TEST(ConstStringRefEqualsCaseInsesitive, WhenStringsDifferOnlyByCaseThenReturnTrue) {
|
||||
EXPECT_TRUE(equalsCaseInsesitive(ConstStringRef("aBc"), ConstStringRef("Abc")));
|
||||
EXPECT_TRUE(equalsCaseInsensitive(ConstStringRef("aBc"), ConstStringRef("Abc")));
|
||||
}
|
||||
|
||||
TEST(ConstStringStartsWith, GivenRightPrefixThenReturnsTrue) {
|
||||
|
||||
Reference in New Issue
Block a user