SWDEV-238517 - [dtest] Catch2 unit tests for device files.
Changes contain Device files under "hip/tests/src/runtimeApi/device" migrated to Catch2 and some additional device tests.
Change-Id: Ie88adc3c32c2079456b14e029cfc6c319b48d8f6
[ROCm/hip commit: 44e1ae449a]
This commit is contained in:
committed by
Sumanth Tumbalam Gooty
orang tua
26cf8d399e
melakukan
9c17929ae4
@@ -13,6 +13,7 @@ target_link_libraries(UnitTests PRIVATE UnitDeviceTests
|
||||
MemoryTest
|
||||
StreamTest
|
||||
OccupancyTest
|
||||
DeviceTest
|
||||
stdc++fs)
|
||||
|
||||
# Add AMD Only Tests
|
||||
|
||||
@@ -2,5 +2,7 @@ add_subdirectory(memory)
|
||||
add_subdirectory(deviceLib)
|
||||
add_subdirectory(stream)
|
||||
add_subdirectory(occupancy)
|
||||
add_subdirectory(device)
|
||||
|
||||
# Disable Saxpy test temporarily to see if CI Passes
|
||||
# add_subdirectory(rtc)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# Common Tests - Test independent of all platforms
|
||||
set(TEST_SRC
|
||||
hipChooseDevice.cc
|
||||
hipDeviceComputeCapability.cc
|
||||
hipDeviceGetByPCIBusId.cc
|
||||
hipDeviceGetLimit.cc
|
||||
hipDeviceGetName.cc
|
||||
hipDeviceGetPCIBusId.cc
|
||||
hipDeviceSetGetCacheConfig.cc
|
||||
hipDeviceSynchronize.cc
|
||||
hipDeviceTotalMem.cc
|
||||
hipGetDeviceAttribute.cc
|
||||
hipGetDeviceCount.cc
|
||||
hipGetDeviceProperties.cc
|
||||
hipRuntimeGetVersion.cc
|
||||
hipSetDeviceFlags.cc
|
||||
hipSetGetDevice.cc
|
||||
)
|
||||
|
||||
|
||||
# Create shared lib of all tests
|
||||
add_library(DeviceTest SHARED EXCLUDE_FROM_ALL ${TEST_SRC})
|
||||
|
||||
# Add dependency on build_tests to build it on this custom target
|
||||
add_dependencies(build_tests DeviceTest)
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
/**
|
||||
* hipChooseDevice tests
|
||||
* Scenario: Validates dev id value.
|
||||
*/
|
||||
TEST_CASE("Unit_hipChooseDevice_ValidateDevId") {
|
||||
hipDeviceProp_t prop;
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, 0));
|
||||
int numDevices = 0;
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
int dev = -1;
|
||||
HIP_CHECK(hipChooseDevice(&dev, &prop));
|
||||
REQUIRE_FALSE(dev < 0);
|
||||
REQUIRE_FALSE(dev >= numDevices);
|
||||
}
|
||||
/**
|
||||
* hipChooseDevice tests
|
||||
* Scenario1: Validates if dev = nullptr returns error code
|
||||
* Scenario2: Validates if prop = nullptr returns error code
|
||||
*/
|
||||
#if HT_AMD
|
||||
// These test scenarios fail on NVIDIA.
|
||||
TEST_CASE("Unit_hipChooseDevice_NegTst") {
|
||||
hipDeviceProp_t prop;
|
||||
int dev = -1;
|
||||
|
||||
// Scenario1
|
||||
SECTION("dev is nullptr") {
|
||||
REQUIRE_FALSE(hipSuccess == hipChooseDevice(nullptr, &prop));
|
||||
}
|
||||
|
||||
// Scenario2
|
||||
SECTION("prop is nullptr") {
|
||||
REQUIRE_FALSE(hipSuccess == hipChooseDevice(&dev, nullptr));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Conformance test for checking functionality of
|
||||
* hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device);
|
||||
*/
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
/**
|
||||
* hipDeviceComputeCapability tests
|
||||
* Scenario1: Validates if &major = nullptr returns error code
|
||||
* Scenario2: Validates if &minor = nullptr returns error code
|
||||
* Scenario3: Check if Major and Minor Versions are valid
|
||||
*/
|
||||
|
||||
// Scenario 1 and 2
|
||||
TEST_CASE("Unit_hipDeviceComputeCapability_NegTst") {
|
||||
int major, minor, numDevices;
|
||||
hipDevice_t device;
|
||||
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
|
||||
if (numDevices > 0) {
|
||||
HIP_CHECK(hipDeviceGet(&device, 0));
|
||||
|
||||
// Scenario1
|
||||
SECTION("major is nullptr") {
|
||||
REQUIRE_FALSE(hipDeviceComputeCapability(nullptr, &minor, device)
|
||||
== hipSuccess);
|
||||
}
|
||||
|
||||
// Scenario2
|
||||
SECTION("minor is nullptr") {
|
||||
REQUIRE_FALSE(hipDeviceComputeCapability(&major, nullptr, device)
|
||||
== hipSuccess);
|
||||
}
|
||||
} else {
|
||||
WARN("Test skipped as no gpu devices available");
|
||||
}
|
||||
}
|
||||
|
||||
// Scenario 3 : Check whether major and minor version value is valid.
|
||||
TEST_CASE("Unit_hipDeviceComputeCapability_ValidateVersion") {
|
||||
int major, minor;
|
||||
hipDevice_t device;
|
||||
int numDevices = -1;
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
HIP_CHECK(hipDeviceGet(&device, i));
|
||||
HIP_CHECK(hipDeviceComputeCapability(&major, &minor, device));
|
||||
REQUIRE(major >= 0);
|
||||
REQUIRE(minor >= 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
#define SIZE 13
|
||||
|
||||
|
||||
/**
|
||||
* scenario: Validates device number from pciBusIdstr string
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetByPCIBusId_Functional") {
|
||||
char pciBusId[SIZE]{};
|
||||
int deviceCount = 0;
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
||||
HIP_ASSERT(deviceCount != 0);
|
||||
for (int i = 0; i < deviceCount; i++) {
|
||||
int pciBusID = -1;
|
||||
int pciDeviceID = -1;
|
||||
int pciDomainID = -1;
|
||||
int tempPciBusId = -1;
|
||||
int tempDeviceId = -1;
|
||||
HIP_CHECK(hipDeviceGetPCIBusId(&pciBusId[0], SIZE, i));
|
||||
sscanf(pciBusId, "%04x:%02x:%02x", &pciDomainID,
|
||||
&pciBusID, &pciDeviceID);
|
||||
HIP_CHECK(hipDeviceGetAttribute(&tempPciBusId,
|
||||
hipDeviceAttributePciBusId, i));
|
||||
|
||||
REQUIRE(pciBusID == tempPciBusId);
|
||||
HIP_CHECK(hipDeviceGetByPCIBusId(&tempDeviceId, pciBusId));
|
||||
REQUIRE(tempDeviceId == i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates negative scenarios for hipDeviceGetByPCIBusId
|
||||
* scenario: device = nullptr and pciBusIdstr = nullptr
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetByPCIBusId_NegativeNullChk") {
|
||||
int device = -1;
|
||||
hipError_t ret;
|
||||
char pciBusIdstr[SIZE]{};
|
||||
ret = hipDeviceGetByPCIBusId(nullptr, pciBusIdstr);
|
||||
CHECK(ret != hipSuccess);
|
||||
|
||||
ret = hipDeviceGetByPCIBusId(&device, nullptr);
|
||||
CHECK(ret != hipSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates negative scenarios for hipDeviceGetByPCIBusId
|
||||
* scenario1: Pass an empty like ""
|
||||
* scenario2: Pass an shorter string "0000:"
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetByPCIBusId_NegativeInputString") {
|
||||
int device = -1;
|
||||
hipError_t ret;
|
||||
ret = hipDeviceGetByPCIBusId(&device, "");
|
||||
CHECK(ret != hipSuccess);
|
||||
|
||||
ret = hipDeviceGetByPCIBusId(&device, "0000:");
|
||||
CHECK(ret != hipSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates negative scenarios for hipDeviceGetByPCIBusId
|
||||
* scenario: Pass wrong bus id in pciBusIdstr
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetByPCIBusId_WrongBusID") {
|
||||
int deviceCount = 0;
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
||||
HIP_ASSERT(deviceCount != 0);
|
||||
constexpr int MaxLen = 20;
|
||||
constexpr int MaxIter = 256;
|
||||
constexpr int MaxBusIdLen = 12;
|
||||
int pciBusId[MaxLen], pciDeviceID[MaxLen],
|
||||
pciDomainID[MaxLen];
|
||||
|
||||
// get bus id of all the devices
|
||||
for (int i = 0; i < deviceCount; i++) {
|
||||
hipDeviceProp_t prop;
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, i));
|
||||
pciBusId[i] = prop.pciBusID;
|
||||
pciDeviceID[i] = prop.pciDeviceID;
|
||||
pciDomainID[i] = prop.pciDomainID;
|
||||
printf("device %d: pciDomainID=%x, pciBusID=%x, pciDeviceID=%x \n",
|
||||
i, prop.pciDomainID, prop.pciBusID, prop.pciDomainID);
|
||||
}
|
||||
// get a non existing bus id
|
||||
int id = 0;
|
||||
for (; id < MaxIter; id++) {
|
||||
bool bFound = false;
|
||||
// check if id is the pci busid of any existing device
|
||||
for (int j = 0; j < deviceCount; j++) {
|
||||
if (id == pciBusId[j]) {
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFound)
|
||||
break;
|
||||
}
|
||||
// now pass the non existing bus id as string
|
||||
char pciBusIdstr[MaxBusIdLen];
|
||||
int device = -1;
|
||||
hipError_t ret;
|
||||
snprintf(pciBusIdstr, sizeof(pciBusIdstr), "%04x:%02x:%02x", pciDomainID[0],
|
||||
id, pciDeviceID[0]);
|
||||
ret = hipDeviceGetByPCIBusId(&device, pciBusIdstr);
|
||||
REQUIRE(ret != hipSuccess);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Conformance test for checking functionality of
|
||||
* hipError_t hipDeviceGetLimit(size_t* pValue, enum hipLimit_t limit);
|
||||
*/
|
||||
#include <hip_test_common.hh>
|
||||
/**
|
||||
* hipDeviceGetLimit tests
|
||||
* Scenario1: Validates if pValue = nullptr returns hip error code.
|
||||
* Scenario2: Validates if *pValue > 0 is returned for limit = hipLimitMallocHeapSize.
|
||||
* Scenario3: Validates if error code is returned for limit = Invalid Flag = 0xff.
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetLimit_NegTst") {
|
||||
size_t Value = 0;
|
||||
// Scenario1
|
||||
SECTION("NULL check") {
|
||||
REQUIRE_FALSE(hipDeviceGetLimit(nullptr, hipLimitMallocHeapSize)
|
||||
== hipSuccess);
|
||||
}
|
||||
// Scenario3
|
||||
SECTION("Invalid Input Flag") {
|
||||
REQUIRE_FALSE(hipDeviceGetLimit(&Value, static_cast<hipLimit_t>(0xff)) ==
|
||||
hipSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipDeviceGetLimit_CheckValidityOfOutputVal") {
|
||||
size_t Value = 0;
|
||||
// Scenario2
|
||||
REQUIRE(hipDeviceGetLimit(&Value, hipLimitMallocHeapSize) ==
|
||||
hipSuccess);
|
||||
REQUIRE_FALSE(Value <= 0);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Conformance test for checking functionality of
|
||||
* hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device);
|
||||
*/
|
||||
#include <hip_test_common.hh>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#define LEN 256
|
||||
/**
|
||||
* hipDeviceGetName tests
|
||||
* Scenario1: Validates the name string with hipDeviceProp_t.name[256]
|
||||
* Scenario2: Validates returned error code for name = nullptr
|
||||
* Scenario3: Validates returned error code for len = 0
|
||||
* Scenario4: Validates returned error code for len < 0
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetName-NegTst") {
|
||||
int numDevices = 0;
|
||||
char name[LEN];
|
||||
hipDevice_t device;
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
HIP_CHECK(hipDeviceGet(&device, i));
|
||||
HIP_CHECK(hipDeviceGetName(name, LEN, device));
|
||||
// Scenario2
|
||||
CHECK_FALSE(hipSuccess == hipDeviceGetName(nullptr, LEN, device));
|
||||
#if HT_AMD
|
||||
// These test scenarios fail on NVIDIA.
|
||||
// Scenario3
|
||||
CHECK_FALSE(hipSuccess == hipDeviceGetName(name, 0, device));
|
||||
// Scenario4
|
||||
CHECK_FALSE(hipSuccess == hipDeviceGetName(name, -1, device));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipDeviceGetName-CheckPropName") {
|
||||
int numDevices = 0;
|
||||
char name[LEN];
|
||||
hipDevice_t device;
|
||||
hipDeviceProp_t prop;
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
HIP_CHECK(hipDeviceGet(&device, i));
|
||||
HIP_CHECK(hipDeviceGetName(name, LEN, device));
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, device));
|
||||
// Scenario1
|
||||
CHECK_FALSE(0 != strcmp(name, prop.name));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test to compare
|
||||
* 1.pciBusID from hipDeviceGetPCIBusId and hipDeviceGetAttribute **
|
||||
* 2.{pciDomainID, pciBusID, pciDeviceID} values hipDeviceGetPCIBusId vs lspci **
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
#define MAX_DEVICE_LENGTH 20
|
||||
|
||||
namespace hipDeviceGetPCIBusIdTests {
|
||||
|
||||
void getPciBusId(int deviceCount,
|
||||
char **hipDeviceList) {
|
||||
for (int i = 0; i < deviceCount; i++) {
|
||||
HIP_CHECK(hipDeviceGetPCIBusId(hipDeviceList[i], MAX_DEVICE_LENGTH, i));
|
||||
}
|
||||
}
|
||||
} // namespace hipDeviceGetPCIBusIdTests
|
||||
|
||||
TEST_CASE("Unit_hipDeviceGetPCIBusId_Check_PciBusID_WithAttr") {
|
||||
int deviceCount = 0;
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
||||
REQUIRE_FALSE(deviceCount == 0);
|
||||
printf("No.of gpus in the system: %d\n", deviceCount);
|
||||
// Allocate an array of pointer to characters
|
||||
char **hipDeviceList = new char*[deviceCount];
|
||||
REQUIRE_FALSE(hipDeviceList == nullptr);
|
||||
for (int i = 0; i < deviceCount; i++) {
|
||||
hipDeviceList[i] = new char[MAX_DEVICE_LENGTH];
|
||||
REQUIRE_FALSE(hipDeviceList[i] == nullptr);
|
||||
}
|
||||
hipDeviceGetPCIBusIdTests::getPciBusId(deviceCount, hipDeviceList);
|
||||
|
||||
for (int i = 0; i < deviceCount; i++) {
|
||||
int pciBusID = -1;
|
||||
int pciDeviceID = -1;
|
||||
int pciDomainID = -1;
|
||||
int tempPciBusId = -1;
|
||||
sscanf(hipDeviceList[i], "%04x:%02x:%02x", &pciDomainID, &pciBusID,
|
||||
&pciDeviceID);
|
||||
HIP_CHECK(hipDeviceGetAttribute(&tempPciBusId,
|
||||
hipDeviceAttributePciBusId, i));
|
||||
REQUIRE_FALSE(pciBusID != tempPciBusId);
|
||||
}
|
||||
// Deallocate
|
||||
for (int i = 0; i < deviceCount; i++) {
|
||||
delete hipDeviceList[i];
|
||||
}
|
||||
delete[] hipDeviceList;
|
||||
printf("pciBusID output of both hipDeviceGetPCIBusId and"
|
||||
" hipDeviceGetAttribute matched for all gpus\n");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates negative scenarios for hipDeviceGetPCIBusId
|
||||
* scenario1: pciBusId = nullptr
|
||||
* scenario2: device = -1 (Invalid Device)
|
||||
* scenario3: device = Non Existing Device
|
||||
* scenario4: len = 0
|
||||
* scenario5: len < 0
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetPCIBusId_NegTst") {
|
||||
char pciBusId[MAX_DEVICE_LENGTH];
|
||||
int device;
|
||||
HIP_CHECK(hipGetDevice(&device));
|
||||
|
||||
// pciBusId is nullptr
|
||||
SECTION("pciBusId is nullptr") {
|
||||
REQUIRE_FALSE(hipDeviceGetPCIBusId(nullptr, MAX_DEVICE_LENGTH, device)
|
||||
== hipSuccess);
|
||||
}
|
||||
|
||||
// len = 0
|
||||
SECTION("len is 0") {
|
||||
REQUIRE_FALSE(hipDeviceGetPCIBusId(pciBusId, 0, device) == hipSuccess);
|
||||
}
|
||||
|
||||
// len < 0
|
||||
SECTION("len is less than 0") {
|
||||
REQUIRE_FALSE(hipDeviceGetPCIBusId(pciBusId, -1, device) == hipSuccess);
|
||||
}
|
||||
|
||||
// device = -1
|
||||
SECTION("device is -1") {
|
||||
REQUIRE_FALSE(hipDeviceGetPCIBusId(pciBusId, MAX_DEVICE_LENGTH, -1)
|
||||
== hipSuccess);
|
||||
}
|
||||
// device = Non Existing Device
|
||||
SECTION("device is -1") {
|
||||
int deviceCount = 0;
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
||||
REQUIRE_FALSE(deviceCount == 0);
|
||||
REQUIRE_FALSE(hipDeviceGetPCIBusId(pciBusId, MAX_DEVICE_LENGTH,
|
||||
deviceCount) == hipSuccess);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#include <hip_test_common.hh>
|
||||
/**
|
||||
* hipDeviceGetCacheConfig tests
|
||||
* Scenario1: Validates if pConfig = nullptr returns hip error code.
|
||||
* Scenario2: Validates if the value returned by hipDeviceGetCacheConfig is valid.
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetCacheConfig_NegTst") {
|
||||
// Scenario1
|
||||
REQUIRE_FALSE(hipSuccess == hipDeviceGetCacheConfig(nullptr));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipDeviceGetCacheConfig_FuncTst") {
|
||||
hipFuncCache_t cacheConfig;
|
||||
// Scenario2
|
||||
HIP_CHECK(hipDeviceGetCacheConfig(&cacheConfig));
|
||||
REQUIRE_FALSE(((cacheConfig != hipFuncCachePreferNone) &&
|
||||
(cacheConfig != hipFuncCachePreferShared) &&
|
||||
(cacheConfig != hipFuncCachePreferL1) &&
|
||||
(cacheConfig != hipFuncCachePreferEqual)));
|
||||
// This code exists to test the dummy implementation of
|
||||
// hipDeviceSetCacheConfig.
|
||||
HIP_CHECK(hipDeviceSetCacheConfig(cacheConfig));
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test for checking the functionality of
|
||||
* hipError_t hipDeviceSynchronize();
|
||||
*/
|
||||
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
#define _SIZE sizeof(int) * 1024 * 1024
|
||||
#define NUM_STREAMS 2
|
||||
|
||||
static __global__ void Iter(int* Ad, int num) {
|
||||
int tx = threadIdx.x + blockIdx.x * blockDim.x;
|
||||
// Kernel loop designed to execute very slowly.
|
||||
// so we can test timing-related
|
||||
// behavior below
|
||||
if (tx == 0) {
|
||||
for (int i = 0; i < num; i++) {
|
||||
Ad[tx] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipDeviceSynchronize_Functional") {
|
||||
int* A[NUM_STREAMS];
|
||||
int* Ad[NUM_STREAMS];
|
||||
hipStream_t stream[NUM_STREAMS];
|
||||
for (int i = 0; i < NUM_STREAMS; i++) {
|
||||
HIP_CHECK(hipHostMalloc(reinterpret_cast<void**>(&A[i]), _SIZE,
|
||||
hipHostMallocDefault));
|
||||
A[i][0] = 1;
|
||||
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&Ad[i]), _SIZE));
|
||||
HIP_CHECK(hipStreamCreate(&stream[i]));
|
||||
}
|
||||
for (int i = 0; i < NUM_STREAMS; i++) {
|
||||
HIP_CHECK(hipMemcpyAsync(Ad[i], A[i], _SIZE, hipMemcpyHostToDevice,
|
||||
stream[i]));
|
||||
}
|
||||
for (int i = 0; i < NUM_STREAMS; i++) {
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(Iter), dim3(1), dim3(1), 0,
|
||||
stream[i], Ad[i], 1 << 30);
|
||||
}
|
||||
for (int i = 0; i < NUM_STREAMS; i++) {
|
||||
HIP_CHECK(hipMemcpyAsync(A[i], Ad[i], _SIZE, hipMemcpyDeviceToHost,
|
||||
stream[i]));
|
||||
}
|
||||
|
||||
|
||||
// This first check but relies on the kernel running for so long that the
|
||||
// D2H async memcopy has not started yet. This will be true in an optimal
|
||||
// asynchronous implementation.
|
||||
// Conservative implementations which synchronize the hipMemcpyAsync will
|
||||
// fail, ie if HIP_LAUNCH_BLOCKING=true.
|
||||
|
||||
CHECK(1 << 30 != A[NUM_STREAMS - 1][0] - 1);
|
||||
HIP_CHECK(hipDeviceSynchronize());
|
||||
CHECK(1 << 30 == A[NUM_STREAMS - 1][0] - 1);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Conformance test for checking functionality of
|
||||
* hipError_t hipDeviceTotalMem(size_t* bytes, hipDevice_t device);
|
||||
*/
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
|
||||
/**
|
||||
* hipDeviceTotalMem tests
|
||||
* Scenario1: Validates if bytes = nullptr returns hip error code.
|
||||
* Scenario2: Validates if error code is returned for device = -1.
|
||||
* Scenario3: Validates if error code is returned for device = deviceCount.
|
||||
* Scenario4: Compare total memory size with hipDeviceProp_t.totalGlobalMem for each device.
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceTotalMem_NegTst") {
|
||||
#if HT_NVIDIA
|
||||
HIP_CHECK(hipInit(0));
|
||||
#endif
|
||||
// Scenario 1
|
||||
SECTION("bytes is nullptr") {
|
||||
REQUIRE_FALSE(hipDeviceTotalMem(nullptr, 0) == hipSuccess);
|
||||
}
|
||||
|
||||
size_t totMem;
|
||||
// Scenario 2
|
||||
SECTION("device is -1") {
|
||||
REQUIRE_FALSE(hipDeviceTotalMem(&totMem, -1) == hipSuccess);
|
||||
}
|
||||
|
||||
// Scenario 3
|
||||
SECTION("pi is nullptr") {
|
||||
int numDevices;
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
size_t totMem;
|
||||
REQUIRE_FALSE(hipDeviceTotalMem(&totMem, numDevices) == hipSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Scenario 4
|
||||
TEST_CASE("Unit_hipDeviceTotalMem_ValidateTotalMem") {
|
||||
size_t totMem;
|
||||
int numDevices;
|
||||
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
REQUIRE(numDevices != 0);
|
||||
|
||||
hipDevice_t device;
|
||||
hipDeviceProp_t prop;
|
||||
auto devNo = GENERATE_COPY(range(0, numDevices));
|
||||
totMem = 0;
|
||||
HIP_CHECK(hipDeviceGet(&device, devNo));
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, device));
|
||||
HIP_CHECK(hipDeviceTotalMem(&totMem, device));
|
||||
REQUIRE_FALSE(totMem != prop.totalGlobalMem);
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
// Test the device info API extensions for HIP
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
static hipError_t test_hipDeviceGetAttribute(int deviceId,
|
||||
hipDeviceAttribute_t attr,
|
||||
int expectedValue = -1) {
|
||||
int value = 0;
|
||||
std::cout << "Test hipDeviceGetAttribute attribute " << attr;
|
||||
if (expectedValue != -1) {
|
||||
std::cout << " expected value " << expectedValue;
|
||||
}
|
||||
HIP_CHECK(hipDeviceGetAttribute(&value, attr, deviceId));
|
||||
std::cout << " actual value " << value << std::endl;
|
||||
if ((expectedValue != -1) && value != expectedValue) {
|
||||
std::cout << "fail" << std::endl;
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
static hipError_t test_hipDeviceGetHdpAddress(int deviceId,
|
||||
hipDeviceAttribute_t attr,
|
||||
uint32_t* expectedValue) {
|
||||
uint32_t* value = 0;
|
||||
std::cout << "Test hipDeviceGetHdpAddress attribute " << attr;
|
||||
if (expectedValue != reinterpret_cast<uint32_t*>(0xdeadbeef)) {
|
||||
std::cout << " expected value " << expectedValue;
|
||||
}
|
||||
HIP_CHECK(hipDeviceGetAttribute(reinterpret_cast<int*>(&value),
|
||||
attr, deviceId));
|
||||
std::cout << " actual value " << value << std::endl;
|
||||
if ((expectedValue != reinterpret_cast<uint32_t*>(0xdeadbeef)) &&
|
||||
value != expectedValue) {
|
||||
std::cout << "fail" << std::endl;
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGetDeviceAttribute_CheckAttrValues") {
|
||||
int deviceId;
|
||||
HIP_CHECK(hipGetDevice(&deviceId));
|
||||
hipDeviceProp_t props;
|
||||
HIP_CHECK(hipGetDeviceProperties(&props, deviceId));
|
||||
printf("info: running on device #%d %s\n", deviceId, props.name);
|
||||
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxThreadsPerBlock,
|
||||
props.maxThreadsPerBlock));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxBlockDimX,
|
||||
props.maxThreadsDim[0]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxBlockDimY,
|
||||
props.maxThreadsDim[1]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxBlockDimZ,
|
||||
props.maxThreadsDim[2]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxGridDimX,
|
||||
props.maxGridSize[0]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxGridDimY,
|
||||
props.maxGridSize[1]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxGridDimZ,
|
||||
props.maxGridSize[2]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxSharedMemoryPerBlock,
|
||||
props.sharedMemPerBlock));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeTotalConstantMemory,
|
||||
props.totalConstMem));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeWarpSize,
|
||||
props.warpSize));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxRegistersPerBlock,
|
||||
props.regsPerBlock));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeClockRate,
|
||||
props.clockRate));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMemoryClockRate,
|
||||
props.memoryClockRate));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMemoryBusWidth,
|
||||
props.memoryBusWidth));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMultiprocessorCount,
|
||||
props.multiProcessorCount));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeIsMultiGpuBoard,
|
||||
props.isMultiGpuBoard));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeComputeMode,
|
||||
props.computeMode));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeL2CacheSize,
|
||||
props.l2CacheSize));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxThreadsPerMultiProcessor,
|
||||
props.maxThreadsPerMultiProcessor));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeComputeCapabilityMajor,
|
||||
props.major));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeComputeCapabilityMinor,
|
||||
props.minor));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeConcurrentKernels,
|
||||
props.concurrentKernels));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributePciBusId,
|
||||
props.pciBusID));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributePciDeviceId,
|
||||
props.pciDeviceID));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxSharedMemoryPerMultiprocessor,
|
||||
props.maxSharedMemoryPerMultiProcessor));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeIntegrated,
|
||||
props.integrated));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxTexture1DWidth,
|
||||
props.maxTexture1D));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxTexture2DWidth,
|
||||
props.maxTexture2D[0]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxTexture2DHeight,
|
||||
props.maxTexture2D[1]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxTexture3DWidth,
|
||||
props.maxTexture3D[0]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxTexture3DHeight,
|
||||
props.maxTexture3D[1]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxTexture3DDepth,
|
||||
props.maxTexture3D[2]));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeCooperativeLaunch,
|
||||
props.cooperativeLaunch));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeCooperativeMultiDeviceLaunch,
|
||||
props.cooperativeMultiDeviceLaunch));
|
||||
|
||||
#if HT_AMD
|
||||
HIP_CHECK(test_hipDeviceGetHdpAddress(deviceId,
|
||||
hipDeviceAttributeHdpMemFlushCntl,
|
||||
props.hdpMemFlushCntl));
|
||||
HIP_CHECK(test_hipDeviceGetHdpAddress(deviceId,
|
||||
hipDeviceAttributeHdpRegFlushCntl,
|
||||
props.hdpRegFlushCntl));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeDirectManagedMemAccessFromHost,
|
||||
props.directManagedMemAccessFromHost));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeConcurrentManagedAccess,
|
||||
props.concurrentManagedAccess));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributePageableMemoryAccess,
|
||||
props.pageableMemoryAccess));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributePageableMemoryAccessUsesHostPageTables,
|
||||
props.pageableMemoryAccessUsesHostPageTables));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeCooperativeMultiDeviceUnmatchedFunc,
|
||||
props.cooperativeMultiDeviceUnmatchedFunc));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeCooperativeMultiDeviceUnmatchedGridDim,
|
||||
props.cooperativeMultiDeviceUnmatchedGridDim));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeCooperativeMultiDeviceUnmatchedBlockDim,
|
||||
props.cooperativeMultiDeviceUnmatchedBlockDim));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeCooperativeMultiDeviceUnmatchedSharedMem,
|
||||
props.cooperativeMultiDeviceUnmatchedSharedMem));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeAsicRevision,
|
||||
props.asicRevision));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeManagedMemory,
|
||||
props.managedMemory));
|
||||
#endif
|
||||
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeMaxPitch,
|
||||
props.memPitch));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeTextureAlignment,
|
||||
props.textureAlignment));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeKernelExecTimeout,
|
||||
props.kernelExecTimeoutEnabled));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeCanMapHostMemory,
|
||||
props.canMapHostMemory));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeEccEnabled,
|
||||
props.ECCEnabled));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeTexturePitchAlignment,
|
||||
props.texturePitchAlignment));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates negative scenarios for hipDeviceGetAttribute
|
||||
* scenario1: pi = nullptr
|
||||
* scenario2: device = -1 (Invalid Device)
|
||||
* scenario3: device = Non Existing Device
|
||||
* scenario4: attr = Invalid Attribute
|
||||
*/
|
||||
TEST_CASE("Unit_hipDeviceGetAttribute_NegTst") {
|
||||
int deviceCount = 0;
|
||||
int pi = -1;
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
||||
REQUIRE(deviceCount != 0);
|
||||
printf("No.of gpus in the system: %d\n", deviceCount);
|
||||
|
||||
int device;
|
||||
HIP_CHECK(hipGetDevice(&device));
|
||||
|
||||
// pi is nullptr
|
||||
SECTION("pi is nullptr") {
|
||||
REQUIRE_FALSE(hipSuccess == hipDeviceGetAttribute(nullptr,
|
||||
hipDeviceAttributePciBusId, device));
|
||||
}
|
||||
|
||||
// device is -1
|
||||
SECTION("device is -1") {
|
||||
REQUIRE_FALSE(hipSuccess == hipDeviceGetAttribute(&pi,
|
||||
hipDeviceAttributePciBusId, -1));
|
||||
}
|
||||
|
||||
// device is Non Existing Device
|
||||
SECTION("device is Non Existing Device") {
|
||||
REQUIRE_FALSE(hipSuccess == hipDeviceGetAttribute(&pi,
|
||||
hipDeviceAttributePciBusId, deviceCount));
|
||||
}
|
||||
|
||||
// attr is Invalid Attribute
|
||||
SECTION("attr is invalid") {
|
||||
REQUIRE_FALSE(hipSuccess == hipDeviceGetAttribute(&pi,
|
||||
static_cast<hipDeviceAttribute_t>(-1),
|
||||
device));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Conformance test for checking functionality of
|
||||
* hipError_t hipGetDeviceCount(int* count);
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
/**
|
||||
* hipGetDeviceCount tests
|
||||
* Scenario: Validates if &numDevices = nullptr returns error code.
|
||||
*/
|
||||
TEST_CASE("Unit_hipGetDeviceCount_NegTst") {
|
||||
// Scenario1
|
||||
REQUIRE_FALSE(hipGetDeviceCount(nullptr) == hipSuccess);
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
|
||||
#define NUM_OF_ARCHPROP 17
|
||||
#define HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS_IDX 0
|
||||
#define HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH_IDX 1
|
||||
#define HIP_ARCH_HAS_SHARED_INT32_ATOMICS_IDX 2
|
||||
#define HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH_IDX 3
|
||||
#define HIP_ARCH_HAS_FLOAT_ATOMIC_ADD_IDX 4
|
||||
#define HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS_IDX 5
|
||||
#define HIP_ARCH_HAS_SHARED_INT64_ATOMICS_IDX 6
|
||||
#define HIP_ARCH_HAS_DOUBLES_IDX 7
|
||||
#define HIP_ARCH_HAS_WARP_VOTE_IDX 8
|
||||
#define HIP_ARCH_HAS_WARP_BALLOT_IDX 9
|
||||
#define HIP_ARCH_HAS_WARP_SHUFFLE_IDX 10
|
||||
#define HIP_ARCH_HAS_WARP_FUNNEL_SHIFT_IDX 11
|
||||
#define HIP_ARCH_HAS_THREAD_FENCE_SYSTEM_IDX 12
|
||||
#define HIP_ARCH_HAS_SYNC_THREAD_EXT_IDX 13
|
||||
#define HIP_ARCH_HAS_SURFACE_FUNCS_IDX 14
|
||||
#define HIP_ARCH_HAS_3DGRID_IDX 15
|
||||
#define HIP_ARCH_HAS_DYNAMIC_PARALLEL_IDX 16
|
||||
|
||||
__device__ void getArchValuesFromDevice(int *archProp_d) {
|
||||
archProp_d[0] = __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__;
|
||||
archProp_d[1] = __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__;
|
||||
archProp_d[2] = __HIP_ARCH_HAS_SHARED_INT32_ATOMICS__;
|
||||
archProp_d[3] = __HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH__;
|
||||
archProp_d[4] = __HIP_ARCH_HAS_FLOAT_ATOMIC_ADD__;
|
||||
archProp_d[5] = __HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS__;
|
||||
archProp_d[6] = __HIP_ARCH_HAS_SHARED_INT64_ATOMICS__;
|
||||
archProp_d[7] = __HIP_ARCH_HAS_DOUBLES__;
|
||||
archProp_d[8] = __HIP_ARCH_HAS_WARP_VOTE__;
|
||||
archProp_d[9] = __HIP_ARCH_HAS_WARP_BALLOT__;
|
||||
archProp_d[10] = __HIP_ARCH_HAS_WARP_SHUFFLE__;
|
||||
archProp_d[11] = __HIP_ARCH_HAS_WARP_FUNNEL_SHIFT__;
|
||||
archProp_d[12] = __HIP_ARCH_HAS_THREAD_FENCE_SYSTEM__;
|
||||
archProp_d[13] = __HIP_ARCH_HAS_SYNC_THREAD_EXT__;
|
||||
archProp_d[14] = __HIP_ARCH_HAS_SURFACE_FUNCS__;
|
||||
archProp_d[15] = __HIP_ARCH_HAS_3DGRID__;
|
||||
archProp_d[16] = __HIP_ARCH_HAS_DYNAMIC_PARALLEL__;
|
||||
}
|
||||
|
||||
__global__ void mykernel(int *archProp_d) {
|
||||
getArchValuesFromDevice(archProp_d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal Functions
|
||||
*/
|
||||
static void validateDeviceMacro(int *archProp_h, hipDeviceProp_t *prop) {
|
||||
CHECK_FALSE(prop->arch.hasGlobalInt32Atomics !=
|
||||
archProp_h[HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasGlobalFloatAtomicExch !=
|
||||
archProp_h[HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasSharedInt32Atomics !=
|
||||
archProp_h[HIP_ARCH_HAS_SHARED_INT32_ATOMICS_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasSharedFloatAtomicExch !=
|
||||
archProp_h[HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasFloatAtomicAdd !=
|
||||
archProp_h[HIP_ARCH_HAS_FLOAT_ATOMIC_ADD_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasGlobalInt64Atomics !=
|
||||
archProp_h[HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasSharedInt64Atomics !=
|
||||
archProp_h[HIP_ARCH_HAS_SHARED_INT64_ATOMICS_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasDoubles !=
|
||||
archProp_h[HIP_ARCH_HAS_DOUBLES_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasWarpVote !=
|
||||
archProp_h[HIP_ARCH_HAS_WARP_VOTE_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasWarpBallot !=
|
||||
archProp_h[HIP_ARCH_HAS_WARP_BALLOT_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasWarpShuffle !=
|
||||
archProp_h[HIP_ARCH_HAS_WARP_SHUFFLE_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasFunnelShift !=
|
||||
archProp_h[HIP_ARCH_HAS_WARP_FUNNEL_SHIFT_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasThreadFenceSystem !=
|
||||
archProp_h[HIP_ARCH_HAS_THREAD_FENCE_SYSTEM_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasSyncThreadsExt !=
|
||||
archProp_h[HIP_ARCH_HAS_SYNC_THREAD_EXT_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasSurfaceFuncs !=
|
||||
archProp_h[HIP_ARCH_HAS_SURFACE_FUNCS_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.has3dGrid !=
|
||||
archProp_h[HIP_ARCH_HAS_3DGRID_IDX]);
|
||||
|
||||
CHECK_FALSE(prop->arch.hasDynamicParallelism !=
|
||||
archProp_h[HIP_ARCH_HAS_DYNAMIC_PARALLEL_IDX]);
|
||||
}
|
||||
/**
|
||||
* Validates value of __HIP_ARCH_* with deviceProp.arch.has* as follows
|
||||
* __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ == hasGlobalInt32Atomics
|
||||
* __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__ == hasGlobalFloatAtomicExch
|
||||
* __HIP_ARCH_HAS_SHARED_INT32_ATOMICS__ == hasSharedInt32Atomics
|
||||
* __HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH__ == hasSharedFloatAtomicExch
|
||||
* __HIP_ARCH_HAS_FLOAT_ATOMIC_ADD__ == hasFloatAtomicAdd
|
||||
* __HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS__ == hasGlobalInt64Atomics
|
||||
* __HIP_ARCH_HAS_SHARED_INT64_ATOMICS__ == hasSharedInt64Atomics
|
||||
* __HIP_ARCH_HAS_DOUBLES__ == hasDoubles
|
||||
* __HIP_ARCH_HAS_WARP_VOTE__ == hasWarpVote
|
||||
* __HIP_ARCH_HAS_WARP_BALLOT__ == hasWarpBallot
|
||||
* __HIP_ARCH_HAS_WARP_SHUFFLE__ == hasWarpShuffle
|
||||
* __HIP_ARCH_HAS_WARP_FUNNEL_SHIFT__ == hasFunnelShift
|
||||
* __HIP_ARCH_HAS_THREAD_FENCE_SYSTEM__ == hasThreadFenceSystem
|
||||
* __HIP_ARCH_HAS_SYNC_THREAD_EXT__ == hasSyncThreadsExt
|
||||
* __HIP_ARCH_HAS_SURFACE_FUNCS__ == hasSurfaceFuncs
|
||||
* __HIP_ARCH_HAS_3DGRID__ == has3dGrid
|
||||
* __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ == hasDynamicParallelism
|
||||
*/
|
||||
#if HT_AMD
|
||||
TEST_CASE("Unit_hipGetDeviceProperties_ArchPropertiesTst") {
|
||||
int *archProp_h, *archProp_d;
|
||||
archProp_h = new int[NUM_OF_ARCHPROP];
|
||||
hipDeviceProp_t prop;
|
||||
int deviceCount = 0, device;
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
||||
REQUIRE(deviceCount != 0);
|
||||
for (device = 0; device < deviceCount; device++) {
|
||||
// Inititalize archProp_h to 0
|
||||
for (int i = 0; i < NUM_OF_ARCHPROP; i++) {
|
||||
archProp_h[i] = 0;
|
||||
}
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, device));
|
||||
HIP_CHECK(hipSetDevice(device));
|
||||
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&archProp_d),
|
||||
NUM_OF_ARCHPROP*sizeof(int)));
|
||||
HIP_CHECK(hipMemcpy(archProp_d, archProp_h,
|
||||
NUM_OF_ARCHPROP*sizeof(int),
|
||||
hipMemcpyHostToDevice));
|
||||
hipLaunchKernelGGL(mykernel, dim3(1), dim3(1),
|
||||
0, 0, archProp_d);
|
||||
HIP_CHECK(hipMemcpy(archProp_h, archProp_d,
|
||||
NUM_OF_ARCHPROP*sizeof(int), hipMemcpyDeviceToHost));
|
||||
// Validate the host architecture property with device
|
||||
// architecture property.
|
||||
validateDeviceMacro(archProp_h, &prop);
|
||||
HIP_CHECK(hipFree(archProp_d));
|
||||
}
|
||||
delete[] archProp_h;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Validates negative scenarios for hipGetDeviceProperties
|
||||
* scenario1: props = nullptr
|
||||
* scenario2: device = -1 (Invalid Device)
|
||||
* scenario3: device = Non Existing Device
|
||||
*/
|
||||
TEST_CASE("Unit_hipGetDeviceProperties_NegTst") {
|
||||
hipDeviceProp_t prop;
|
||||
|
||||
#if HT_AMD
|
||||
SECTION("props is nullptr") {
|
||||
int device;
|
||||
HIP_CHECK(hipGetDevice(&device));
|
||||
// this test case results in segmentation fault on NVCC
|
||||
REQUIRE_FALSE(hipSuccess == hipGetDeviceProperties(nullptr, device));
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("device is -1") {
|
||||
REQUIRE_FALSE(hipSuccess == hipGetDeviceProperties(&prop, -1));
|
||||
}
|
||||
|
||||
SECTION("device is -1") {
|
||||
int deviceCount = 0;
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
||||
REQUIRE(deviceCount != 0);
|
||||
REQUIRE_FALSE(hipSuccess == hipGetDeviceProperties(&prop, deviceCount));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Conformance test for checking functionality of
|
||||
* hipError_t hipRuntimeGetVersion(int* runtimeVersion);
|
||||
* On HIP/HCC path this function returns HIP runtime patch version
|
||||
* (a 5 digit code) however on
|
||||
* HIP/NVCC path this function return CUDA runtime version.
|
||||
*/
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
TEST_CASE("Unit_hipRuntimeGetVersion_NegAndValTst") {
|
||||
int runtimeVersion = -1;
|
||||
CHECK_FALSE(hipRuntimeGetVersion(nullptr) == hipSuccess);
|
||||
HIP_CHECK(hipRuntimeGetVersion(&runtimeVersion));
|
||||
CHECK_FALSE(runtimeVersion <= 0);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (c) 2021-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
/*
|
||||
* Conformance test for checking functionality of
|
||||
* hipError_t hipGetDeviceFlags(unsigned int* flags);
|
||||
* hipError_t hipSetDeviceFlags(unsigned flags);
|
||||
*/
|
||||
/**
|
||||
* hipGetDeviceFlags and hipSetDeviceFlags tests.
|
||||
* Scenario1: Validates if hipGetDeviceFlags returns hip error code for
|
||||
* flags = nullptr.
|
||||
* Scenario2: Validates if hipSetDeviceFlags returns hip error code for
|
||||
* invalid flag.
|
||||
* Scenario3: Validates if flags = hipDeviceScheduleSpin|hipDeviceScheduleYield
|
||||
* |hipDeviceScheduleBlockingSync|hipDeviceScheduleAuto|hipDeviceMapHost
|
||||
* |hipDeviceLmemResizeToMax returned by hipGetDeviceFlags.
|
||||
*/
|
||||
TEST_CASE("Unit_hipGetDeviceFlags_NegTst") {
|
||||
// Scenario1
|
||||
SECTION("flags is nullptr") {
|
||||
REQUIRE_FALSE(hipSuccess == hipGetDeviceFlags(nullptr));
|
||||
}
|
||||
|
||||
// Scenario2
|
||||
SECTION("flags value is invalid") {
|
||||
REQUIRE_FALSE(hipSuccess == hipSetDeviceFlags(0xffff));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Unit_hipGetDeviceFlags_FuncTst") {
|
||||
unsigned flag = 0;
|
||||
|
||||
// Scenario3
|
||||
SECTION("Check flag value") {
|
||||
HIP_CHECK(hipGetDeviceFlags(&flag));
|
||||
bool checkFlg = false;
|
||||
checkFlg = ((flag != hipDeviceScheduleSpin) &&
|
||||
(flag != hipDeviceScheduleYield) &&
|
||||
(flag != hipDeviceScheduleBlockingSync) &&
|
||||
(flag != hipDeviceScheduleAuto) &&
|
||||
(flag != hipDeviceMapHost) &&
|
||||
(flag != hipDeviceLmemResizeToMax));
|
||||
REQUIRE_FALSE(checkFlg);
|
||||
}
|
||||
|
||||
SECTION("Set flag value") {
|
||||
auto devNo = GENERATE(range(0, HipTest::getDeviceCount()));
|
||||
flag = 0;
|
||||
HIP_CHECK(hipSetDevice(devNo));
|
||||
auto bitmap = GENERATE(range(0, 4));
|
||||
flag = 1 << bitmap;
|
||||
HIP_CHECK(hipSetDeviceFlags(flag));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2021-present Advanced Micro Devices, Inc. All rights reserved.
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Verifies functionality of hipSetDevice/hipGetDevice api.
|
||||
* -- Basic Test to set and get valid device numbers.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
TEST_CASE("Unit_hipSetDevice_BasicSetGet") {
|
||||
int numDevices = 0;
|
||||
int device;
|
||||
int validateCount = 0;
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
REQUIRE(numDevices != 0);
|
||||
|
||||
for (int i = 0; i < numDevices; i++) {
|
||||
HIP_CHECK(hipSetDevice(i));
|
||||
HIP_CHECK(hipGetDevice(&device));
|
||||
if (device == i) {
|
||||
validateCount+= 1;
|
||||
}
|
||||
}
|
||||
|
||||
REQUIRE(numDevices == validateCount);
|
||||
}
|
||||
Reference in New Issue
Block a user