77
88#include " opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h"
99
10+ #include " shared/offline_compiler/source/ocloc_arg_helper.h"
1011#include " shared/source/helpers/hw_helper.h"
1112
1213#include < algorithm>
@@ -17,40 +18,63 @@ namespace NEO {
1718TEST (OclocFatBinaryRequestedFatBinary, WhenDeviceArgMissingThenReturnsFalse) {
1819 const char *args[] = {" ocloc" , " -aaa" , " *" , " -device" , " *" };
1920
20- EXPECT_FALSE (NEO::requestedFatBinary (0 , nullptr ));
21- EXPECT_FALSE (NEO::requestedFatBinary (1 , args));
22- EXPECT_FALSE (NEO::requestedFatBinary (2 , args));
23- EXPECT_FALSE (NEO::requestedFatBinary (3 , args));
24- EXPECT_FALSE (NEO::requestedFatBinary (4 , args));
21+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
22+
23+ EXPECT_FALSE (NEO::requestedFatBinary (0 , nullptr , argHelper.get ()));
24+ EXPECT_FALSE (NEO::requestedFatBinary (1 , args, argHelper.get ()));
25+ EXPECT_FALSE (NEO::requestedFatBinary (2 , args, argHelper.get ()));
26+ EXPECT_FALSE (NEO::requestedFatBinary (3 , args, argHelper.get ()));
27+ EXPECT_FALSE (NEO::requestedFatBinary (4 , args, argHelper.get ()));
2528}
2629
27- TEST (OclocFatBinaryRequestedFatBinary, WhenDeviceArgProvidedAndContainsFatbinaryArgFormatThenReturnsTrue) {
30+ TEST (OclocFatBinaryRequestedFatBinary, GivenDeviceArgProvidedWhenFatBinaryFormatWithRangeIsPassedThenTrueIsReturned) {
31+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
32+
2833 const char *allPlatforms[] = {" ocloc" , " -device" , " *" };
2934 const char *manyPlatforms[] = {" ocloc" , " -device" , " a,b" };
3035 const char *manyGens[] = {" ocloc" , " -device" , " gen0,gen1" };
31- const char *gen[] = {" ocloc" , " -device" , " gen0" };
3236 const char *rangePlatformFrom[] = {" ocloc" , " -device" , " skl-" };
3337 const char *rangePlatformTo[] = {" ocloc" , " -device" , " -skl" };
3438 const char *rangePlatformBounds[] = {" ocloc" , " -device" , " skl-icllp" };
3539 const char *rangeGenFrom[] = {" ocloc" , " -device" , " gen0-" };
3640 const char *rangeGenTo[] = {" ocloc" , " -device" , " -gen5" };
3741 const char *rangeGenBounds[] = {" ocloc" , " -device" , " gen0-gen5" };
3842
39- EXPECT_TRUE (NEO::requestedFatBinary (3 , allPlatforms));
40- EXPECT_TRUE (NEO::requestedFatBinary (3 , manyPlatforms));
41- EXPECT_TRUE (NEO::requestedFatBinary (3 , manyGens));
42- EXPECT_TRUE (NEO::requestedFatBinary (3 , gen));
43- EXPECT_TRUE (NEO::requestedFatBinary (3 , rangePlatformFrom));
44- EXPECT_TRUE (NEO::requestedFatBinary (3 , rangePlatformTo));
45- EXPECT_TRUE (NEO::requestedFatBinary (3 , rangePlatformBounds));
46- EXPECT_TRUE (NEO::requestedFatBinary (3 , rangeGenFrom));
47- EXPECT_TRUE (NEO::requestedFatBinary (3 , rangeGenTo));
48- EXPECT_TRUE (NEO::requestedFatBinary (3 , rangeGenBounds));
43+ EXPECT_TRUE (NEO::requestedFatBinary (3 , allPlatforms, argHelper.get ()));
44+ EXPECT_TRUE (NEO::requestedFatBinary (3 , manyPlatforms, argHelper.get ()));
45+ EXPECT_TRUE (NEO::requestedFatBinary (3 , manyGens, argHelper.get ()));
46+ EXPECT_TRUE (NEO::requestedFatBinary (3 , rangePlatformFrom, argHelper.get ()));
47+ EXPECT_TRUE (NEO::requestedFatBinary (3 , rangePlatformTo, argHelper.get ()));
48+ EXPECT_TRUE (NEO::requestedFatBinary (3 , rangePlatformBounds, argHelper.get ()));
49+ EXPECT_TRUE (NEO::requestedFatBinary (3 , rangeGenFrom, argHelper.get ()));
50+ EXPECT_TRUE (NEO::requestedFatBinary (3 , rangeGenTo, argHelper.get ()));
51+ EXPECT_TRUE (NEO::requestedFatBinary (3 , rangeGenBounds, argHelper.get ()));
52+ }
53+
54+ TEST (OclocFatBinaryRequestedFatBinary, GivenDeviceArgProvidedWhenUnknownGenNameIsPassedThenRequestedFatBinaryReturnsFalse) {
55+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
56+ const char *unknownGen[] = {" ocloc" , " -device" , " gen0" };
57+ const char *unknownGenCaseInsensitive[] = {" ocloc" , " -device" , " Gen0" };
58+
59+ EXPECT_FALSE (NEO::requestedFatBinary (3 , unknownGen, argHelper.get ()));
60+ EXPECT_FALSE (NEO::requestedFatBinary (3 , unknownGenCaseInsensitive, argHelper.get ()));
61+ }
62+
63+ TEST (OclocFatBinaryRequestedFatBinary, GivenDeviceArgProvidedWhenKnownGenNameIsPassedThenRequestedFatBinaryReturnsTrue) {
64+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
65+ unsigned int i = 0 ;
66+ for (; i < IGFX_MAX_CORE; ++i) {
67+ if (NEO::familyName[i] != nullptr )
68+ break ;
69+ }
70+ const char *genFromFamilyName[] = {" ocloc" , " -device" , NEO::familyName[i]};
71+ EXPECT_TRUE (NEO::requestedFatBinary (3 , genFromFamilyName, argHelper.get ()));
4972}
5073
5174TEST (OclocFatBinaryRequestedFatBinary, WhenDeviceArgProvidedButDoesnNotContainFatbinaryArgFormatThenReturnsFalse) {
75+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
5276 const char *skl[] = {" ocloc" , " -device" , " skl" };
53- EXPECT_FALSE (NEO::requestedFatBinary (3 , skl));
77+ EXPECT_FALSE (NEO::requestedFatBinary (3 , skl, argHelper. get () ));
5478}
5579
5680TEST (OclocFatBinaryGetAllSupportedTargetPlatforms, WhenRequestedThenReturnsAllPlatformsWithNonNullHardwarePrefixes) {
@@ -91,21 +115,51 @@ TEST(OclocFatBinaryAsProductId, GivenDisabledPlatformNameThenReturnsUnknownPlatf
91115}
92116
93117TEST (OclocFatBinaryAsGfxCoreIdList, GivenEnabledGfxCoreNameThenReturnsNonEmptyList) {
118+
119+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
120+
94121 for (unsigned int coreId = 0 ; coreId < IGFX_MAX_CORE; ++coreId) {
95122 if (nullptr != NEO::familyName[coreId]) {
96- EXPECT_FALSE ( NEO::asGfxCoreIdList (ConstStringRef (NEO::familyName[coreId], strlen (NEO::familyName[coreId]))). empty ( ));
97- std::string caseInsesitive = NEO::familyName[coreId];
98- caseInsesitive[ 0 ] = ' g ' ;
99- EXPECT_FALSE ( NEO::asGfxCoreIdList (caseInsesitive). empty ( ));
123+ EXPECT_TRUE (argHelper-> isGen (ConstStringRef (NEO::familyName[coreId]). str () ));
124+ std::string caseInsensitive = NEO::familyName[coreId];
125+ std::transform (caseInsensitive. begin (), caseInsensitive. begin () + 1 , caseInsensitive. begin (), ::tolower) ;
126+ EXPECT_TRUE (argHelper-> isGen (caseInsensitive ));
100127 }
101128 }
102129}
103130
104131TEST (OclocFatBinaryAsGfxCoreIdList, GivenDisabledGfxCoreNameThenReturnsEmptyList) {
105- EXPECT_TRUE (NEO::asGfxCoreIdList (ConstStringRef (" genA" )).empty ());
106- EXPECT_TRUE (NEO::asGfxCoreIdList (ConstStringRef (" gen0" )).empty ());
107- EXPECT_TRUE (NEO::asGfxCoreIdList (ConstStringRef (" gen1" )).empty ());
108- EXPECT_TRUE (NEO::asGfxCoreIdList (ConstStringRef (" gen2" )).empty ());
132+
133+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
134+
135+ EXPECT_FALSE (argHelper->isGen (ConstStringRef (" genA" ).str ()));
136+ EXPECT_FALSE (argHelper->isGen (ConstStringRef (" gen0" ).str ()));
137+ EXPECT_FALSE (argHelper->isGen (ConstStringRef (" gen1" ).str ()));
138+ EXPECT_FALSE (argHelper->isGen (ConstStringRef (" gen2" ).str ()));
139+ }
140+
141+ TEST (OclocFatBinaryAsGfxCoreIdList, GivenEnabledGfxCoreNameThenReturnsNonNullIGFX) {
142+
143+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
144+
145+ for (unsigned int coreId = 0 ; coreId < IGFX_MAX_CORE; ++coreId) {
146+ if (nullptr != NEO::familyName[coreId]) {
147+ EXPECT_EQ (argHelper->returnIGFXforGen (ConstStringRef (NEO::familyName[coreId]).str ()), coreId);
148+ std::string caseInsensitive = NEO::familyName[coreId];
149+ std::transform (caseInsensitive.begin (), caseInsensitive.begin () + 1 , caseInsensitive.begin (), ::tolower);
150+ EXPECT_EQ (argHelper->returnIGFXforGen (caseInsensitive), coreId);
151+ }
152+ }
153+ }
154+
155+ TEST (OclocFatBinaryAsGfxCoreIdList, GivenDisabledGfxCoreNameThenReturnsNullIGFX) {
156+
157+ std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
158+
159+ EXPECT_EQ (argHelper->returnIGFXforGen (ConstStringRef (" genA" ).str ()), 0u );
160+ EXPECT_EQ (argHelper->returnIGFXforGen (ConstStringRef (" gen0" ).str ()), 0u );
161+ EXPECT_EQ (argHelper->returnIGFXforGen (ConstStringRef (" gen1" ).str ()), 0u );
162+ EXPECT_EQ (argHelper->returnIGFXforGen (ConstStringRef (" gen2" ).str ()), 0u );
109163}
110164
111165TEST (OclocFatBinaryAppendPlatformsForGfxCore, GivenCoreIdThenAppendsEnabledProductIdsThatMatch) {
0 commit comments