SWDEV-299127 - Merge 'develop' into 'amd-staging'
Change-Id: I8a8c629fd733b79dfd06dc44a72c5d2661cdc026
Bu işleme şunda yer alıyor:
@@ -574,7 +574,7 @@ enum hipLimit_t {
|
||||
/** Disable event's capability to record timing information. May improve performance.*/
|
||||
#define hipEventDisableTiming 0x2
|
||||
|
||||
/** Event can support IPC. Warnig: It is not supported in HIP.*/
|
||||
/** Event can support IPC. hipEventDisableTiming also must be set.*/
|
||||
#define hipEventInterprocess 0x4
|
||||
|
||||
/** Use a device-scope release when recording this event. This flag is useful to obtain more
|
||||
@@ -1713,13 +1713,13 @@ hipError_t hipIpcCloseMemHandle(void* devPtr);
|
||||
/**
|
||||
* @brief Gets an opaque interprocess handle for an event.
|
||||
*
|
||||
* This opaque handle may be copied into other processes and opened with cudaIpcOpenEventHandle.
|
||||
* Then cudaEventRecord, cudaEventSynchronize, cudaStreamWaitEvent and cudaEventQuery may be used in
|
||||
* This opaque handle may be copied into other processes and opened with hipIpcOpenEventHandle.
|
||||
* Then hipEventRecord, hipEventSynchronize, hipStreamWaitEvent and hipEventQuery may be used in
|
||||
* either process. Operations on the imported event after the exported event has been freed with hipEventDestroy
|
||||
* will result in undefined behavior.
|
||||
*
|
||||
* @param[out] handle Pointer to cudaIpcEventHandle to return the opaque event handle
|
||||
* @param[in] event Event allocated with cudaEventInterprocess and cudaEventDisableTiming flags
|
||||
* @param[out] handle Pointer to hipIpcEventHandle to return the opaque event handle
|
||||
* @param[in] event Event allocated with hipEventInterprocess and hipEventDisableTiming flags
|
||||
*
|
||||
* @returns #hipSuccess, #hipErrorInvalidConfiguration, #hipErrorInvalidValue
|
||||
*
|
||||
@@ -2227,8 +2227,8 @@ hipError_t hipStreamWriteValue64(hipStream_t stream, void* ptr, uint64_t value,
|
||||
for the synchroniation but can result in lower power and more resources for other CPU threads.
|
||||
* #hipEventDisableTiming : Disable recording of timing information. Events created with this flag
|
||||
would not record profiling data and provide best performance if used for synchronization.
|
||||
* @warning On AMD platform, hipEventInterprocess support is under development. Use of this flag
|
||||
will return an error.
|
||||
* #hipEventInterprocess : The event can be used as an interprocess event. hipEventDisableTiming
|
||||
flag also must be set when hipEventInterprocess flag is set.
|
||||
*
|
||||
* @returns #hipSuccess, #hipErrorNotInitialized, #hipErrorInvalidValue,
|
||||
#hipErrorLaunchFailure, #hipErrorOutOfMemory
|
||||
|
||||
+14
-8
@@ -149,19 +149,25 @@ Here "-C performance" indicate the "performance" configuration of ctest.
|
||||
|
||||
### RTC Testing
|
||||
|
||||
To enable RTC testing, cmake needs to be passed the DRTC_TESTING=1 options.
|
||||
To enable RTC testing, cmake needs to be passed the `-DRTC_TESTING=1` option.
|
||||
|
||||
When this option is passed, all tests that support this functionality will be run using HIP RTC to compile and run.
|
||||
|
||||
To enable HIP RTC support for a specific test:
|
||||
1 - Move all its kernels to tests/catch/kernels (one file per kernel)
|
||||
2 - Update tests/catch/kernels/CMakeLists.txt
|
||||
3 - Update tests/catch/include/kernels.hh
|
||||
4 - Update tests/catch/include/kernel_mapping.hh
|
||||
5 - Include kernels.hh
|
||||
6 - Call hipTest::launchKernel() function instead of hipLaunchKernelGGL()
|
||||
|
||||
Note: HIP RTC does not do implicit casting of kernel parameters. This requires the test writer to explicitly do all the casting before running the kernel. The code will not compile otherwise.
|
||||
1. Move all its kernels to `tests/catch/kernels` (one file per kernel):
|
||||
1. Kernel **functions** should use the file extension `.cpp` and include `kernels.hh`
|
||||
2. Kernel **templates** should use the file extension `.inl`
|
||||
2. Update `tests/catch/kernels/CMakeLists.txt` (i.e. add the new kernel **functions** to `TEST_SRC`)
|
||||
3. Update `tests/catch/include/kernels.hh`:
|
||||
1. Declare the new kernel **functions**
|
||||
2. Include the new .inl files that contain kernel **templates**
|
||||
3. Call the `FUNCTION_WRAPPER` and `TEMPLATE_WRAPPER` macros for each new function and template respectively.
|
||||
4. Update `tests/catch/include/kernel_mapping.hh` with the mapping between the new files and respective function / template names.
|
||||
5. Include `kernels.hh`
|
||||
6. Call the `hipTest::launchKernel()` function instead of `hipLaunchKernelGGL()`
|
||||
|
||||
**Note:** HIP RTC does not do implicit casting of kernel parameters. This **requires** the test writer to explicitly do all the casting before running the kernel. There is a `static_assert` inside `hipTest::launchKernel()` that checks that this was done correctly. However, due to limitations, the assertion is only performed when `-DRTC_TESTING` option is **disabled**. This means that runtime errors can occur if the casts are not performed correctly and `-DRTC_TESTING` is enabled.
|
||||
|
||||
### If a test fails - how to debug a test
|
||||
|
||||
|
||||
@@ -204,9 +204,9 @@ function(hip_add_exe_to_target)
|
||||
)
|
||||
# Create shared lib of all tests
|
||||
if(NOT RTC_TESTING)
|
||||
add_executable(${_NAME} EXCLUDE_FROM_ALL ${_TEST_SRC} $<TARGET_OBJECTS:Main_Object> $<TARGET_OBJECTS:KERNELS>)
|
||||
add_executable(${_NAME} EXCLUDE_FROM_ALL ${_TEST_SRC} $<TARGET_OBJECTS:Main_Object> $<TARGET_OBJECTS:KERNELS>)
|
||||
else ()
|
||||
add_executable(${_NAME} EXCLUDE_FROM_ALL ${_TEST_SRC} $<TARGET_OBJECTS:Main_Object>)
|
||||
add_executable(${_NAME} EXCLUDE_FROM_ALL ${_TEST_SRC} $<TARGET_OBJECTS:Main_Object>)
|
||||
if(HIP_PLATFORM STREQUAL "amd")
|
||||
target_link_libraries(${_NAME} hiprtc)
|
||||
else()
|
||||
|
||||
@@ -1,45 +1,14 @@
|
||||
{
|
||||
"DisabledTests":
|
||||
[
|
||||
"Unit_hipMemcpy3D_Basic - int",
|
||||
"Unit_hipMemcpy3D_Basic - unsigned int",
|
||||
"Unit_hipMemcpy3D_Basic - float",
|
||||
"Unit_hipMemcpy3DAsync_Basic - int",
|
||||
"Unit_hipMemcpy3DAsync_Basic - unsigned int",
|
||||
"Unit_hipMemcpy3DAsync_Basic - float",
|
||||
"Unit_hipMemcpy3DAsync_multiDevice-Negative",
|
||||
"Unit_hipMemcpy3DAsync_multiDevice-DiffStream",
|
||||
"Unit_hipPointerGetAttributes_ClusterAlloc",
|
||||
"Unit_hipMallocManaged_MultiChunkMultiDevice",
|
||||
"Unit_hipMallocManaged_TwoPointers - int",
|
||||
"Unit_hipMallocManaged_TwoPointers - float",
|
||||
"Unit_hipMallocManaged_TwoPointers - double",
|
||||
"Unit_hipMallocManaged_DeviceContextChange - unsigned char",
|
||||
"Unit_hipMallocManaged_DeviceContextChange - int",
|
||||
"Unit_hipMallocManaged_DeviceContextChange - float",
|
||||
"Unit_hipMallocManaged_DeviceContextChange - double",
|
||||
"Unit_hipHostMalloc_CoherentTst",
|
||||
"Unit_hipMallocManaged_CoherentTst",
|
||||
"Unit_hipMallocManaged_CoherentTstWthAdvise",
|
||||
"Unit_hipMalloc_CoherentTst",
|
||||
"Unit_hipExtMallocWithFlags_CoherentTst",
|
||||
"Unit_printf_flags",
|
||||
"Unit_printf_specifier",
|
||||
"Unit_hipTextureObj2D_Check",
|
||||
"Unit_hipTextureMipmapObj2D_Check",
|
||||
"Unit_hipStreamPerThread_DeviceReset_1",
|
||||
"Unit_hipStreamPerThread_DeviceReset_2",
|
||||
"Unit_hipManagedKeyword_MultiGpu",
|
||||
"Unit_hipGraphAddHostNode_ClonedGraphwithHostNode",
|
||||
"Unit_hipGraphAddChildGraphNode_OrgGraphAsChildGraph",
|
||||
"Unit_hipGraphAddChildGraphNode_SingleChildNode",
|
||||
"Unit_hipPtrGetAttribute_Simple",
|
||||
"Unit_hipStreamCreateWithPriority_ValidateWithEvents",
|
||||
"Unit_hipEvent",
|
||||
"Unit_hipHostMalloc_NonCoherent",
|
||||
"Unit_hipHostMalloc_Coherent",
|
||||
"Unit_hipHostMalloc_Default",
|
||||
"Unit_hipStreamCreate_MultistreamBasicFunctionalities",
|
||||
"Unit_hipEventIpc",
|
||||
"Unit_hipMalloc3D_Negative",
|
||||
"Unit_hipPointerGetAttribute_MappedMem",
|
||||
@@ -51,8 +20,6 @@
|
||||
"Unit_hipStreamGetCaptureInfo_hipStreamPerThread",
|
||||
"Unit_hipStreamGetCaptureInfo_UniqueID",
|
||||
"Unit_hipStreamGetCaptureInfo_ArgValidation",
|
||||
"# Following test is related to ticket EXSWCPHIPT-41",
|
||||
"Unit_hipStreamGetPriority_happy",
|
||||
"Unit_hipMemPoolApi_Basic",
|
||||
"Unit_hipMemPoolApi_BasicAlloc",
|
||||
"Unit_hipMemPoolApi_BasicTrim",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <cstdlib>
|
||||
#include <hip_test_common.hh>
|
||||
#include <picojson.h>
|
||||
#include <fstream>
|
||||
@@ -211,7 +212,10 @@ bool TestContext::parseJsonFile() {
|
||||
|
||||
void TestContext::cleanContext() {
|
||||
for (auto& pair : compiledKernels) {
|
||||
REQUIRE(hipSuccess == hipModuleUnload(pair.second.module));
|
||||
hipError_t error = hipModuleUnload(pair.second.module);
|
||||
if (error != hipSuccess) {
|
||||
throw std::runtime_error("Unable to unload rtc module");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,5 +9,8 @@ int main(int argc, char** argv) {
|
||||
std::cout << "HIP_SKIP_THIS_TEST" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
return Catch::Session().run(argc, argv);
|
||||
int out = Catch::Session().run(argc, argv);
|
||||
TestContext::get().cleanContext();
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ THE SOFTWARE.
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
#include "hip/hip_runtime_api.h"
|
||||
#include "hip_test_context.hh"
|
||||
|
||||
@@ -218,7 +219,6 @@ static inline void printInfo() {
|
||||
template <typename... Typenames, typename... Args>
|
||||
void launchRTCKernel(std::string (*getKernelName)(), dim3 numBlocks, dim3 numThreads,
|
||||
std::uint32_t memPerBlock, hipStream_t stream, Args&&... packedArgs) {
|
||||
|
||||
printInfo();
|
||||
TestContext& testContext = TestContext::get();
|
||||
std::string kernelName = (*getKernelName)();
|
||||
@@ -226,25 +226,29 @@ void launchRTCKernel(std::string (*getKernelName)(), dim3 numBlocks, dim3 numThr
|
||||
std::vector<std::string> kernelTypenames{std::string(HipTest::getTypeName<Typenames>())...};
|
||||
std::string kernelExpression = reconstructExpression(kernelName, kernelTypenames);
|
||||
|
||||
if (testContext.getFunction(kernelExpression) == nullptr) {
|
||||
hiprtcProgram rtcProgram{compileRTC(kernelName, kernelExpression)};
|
||||
std::vector<char> compiledCode{getKernelCode(rtcProgram)};
|
||||
static std::mutex mutex{};
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuard(mutex);
|
||||
if (testContext.getFunction(kernelExpression) == nullptr) {
|
||||
hiprtcProgram rtcProgram{compileRTC(kernelName, kernelExpression)};
|
||||
std::vector<char> compiledCode{getKernelCode(rtcProgram)};
|
||||
|
||||
hipModule_t module;
|
||||
hipModule_t module;
|
||||
|
||||
REQUIRE(hipSuccess == hipModuleLoadData(&module, compiledCode.data()));
|
||||
REQUIRE(hipSuccess == hipModuleLoadData(&module, compiledCode.data()));
|
||||
|
||||
hipFunction_t kernelFunction;
|
||||
|
||||
const char* loweredName;
|
||||
REQUIRE(HIPRTC_SUCCESS ==
|
||||
hiprtcGetLoweredName(rtcProgram, kernelExpression.c_str(), &loweredName));
|
||||
REQUIRE(hipSuccess == hipModuleGetFunction(&kernelFunction, module, loweredName));
|
||||
const char* loweredName;
|
||||
REQUIRE(HIPRTC_SUCCESS ==
|
||||
hiprtcGetLoweredName(rtcProgram, kernelExpression.c_str(), &loweredName));
|
||||
REQUIRE(hipSuccess == hipModuleGetFunction(&kernelFunction, module, loweredName));
|
||||
|
||||
/* After obtaining the kernelFunction, the program is no longer needed. So it can be destroyed */
|
||||
REQUIRE(HIPRTC_SUCCESS == hiprtcDestroyProgram(&rtcProgram));
|
||||
/* After obtaining the kernelFunction, the program is no longer needed. So it can be destroyed */
|
||||
REQUIRE(HIPRTC_SUCCESS == hiprtcDestroyProgram(&rtcProgram));
|
||||
|
||||
testContext.trackRtcState(kernelExpression, module, kernelFunction);
|
||||
testContext.trackRtcState(kernelExpression, module, kernelFunction);
|
||||
}
|
||||
}
|
||||
|
||||
hipFunction_t kernelFunction = testContext.getFunction(kernelExpression);
|
||||
|
||||
@@ -13,11 +13,12 @@ set(TEST_SRC
|
||||
hipGetDeviceCount.cc
|
||||
hipGetDeviceProperties.cc
|
||||
hipRuntimeGetVersion.cc
|
||||
hipSetDeviceFlags.cc
|
||||
hipGetSetDeviceFlags.cc
|
||||
hipSetGetDevice.cc
|
||||
hipDeviceGetUuid.cc
|
||||
)
|
||||
|
||||
hip_add_exe_to_target(NAME DeviceTest
|
||||
TEST_SRC ${TEST_SRC}
|
||||
TEST_TARGET_NAME build_tests)
|
||||
TEST_TARGET_NAME build_tests
|
||||
COMPILE_OPTIONS -std=c++14)
|
||||
|
||||
@@ -37,13 +37,13 @@ TEST_CASE("Unit_hipDeviceTotalMem_NegTst") {
|
||||
#endif
|
||||
// Scenario 1
|
||||
SECTION("bytes is nullptr") {
|
||||
REQUIRE_FALSE(hipDeviceTotalMem(nullptr, 0) == hipSuccess);
|
||||
HIP_CHECK_ERROR(hipDeviceTotalMem(nullptr, 0), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
size_t totMem;
|
||||
// Scenario 2
|
||||
SECTION("device is -1") {
|
||||
REQUIRE_FALSE(hipDeviceTotalMem(&totMem, -1) == hipSuccess);
|
||||
HIP_CHECK_ERROR(hipDeviceTotalMem(&totMem, -1), hipErrorInvalidDevice);
|
||||
}
|
||||
|
||||
// Scenario 3
|
||||
@@ -51,14 +51,14 @@ TEST_CASE("Unit_hipDeviceTotalMem_NegTst") {
|
||||
int numDevices;
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
size_t totMem;
|
||||
REQUIRE_FALSE(hipDeviceTotalMem(&totMem, numDevices) == hipSuccess);
|
||||
HIP_CHECK_ERROR(hipDeviceTotalMem(&totMem, numDevices), hipErrorInvalidDevice);
|
||||
}
|
||||
}
|
||||
|
||||
// Scenario 4
|
||||
TEST_CASE("Unit_hipDeviceTotalMem_ValidateTotalMem") {
|
||||
size_t totMem;
|
||||
int numDevices;
|
||||
int numDevices = 0;
|
||||
|
||||
HIP_CHECK(hipGetDeviceCount(&numDevices));
|
||||
REQUIRE(numDevices != 0);
|
||||
@@ -70,5 +70,30 @@ TEST_CASE("Unit_hipDeviceTotalMem_ValidateTotalMem") {
|
||||
HIP_CHECK(hipDeviceGet(&device, devNo));
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, device));
|
||||
HIP_CHECK(hipDeviceTotalMem(&totMem, device));
|
||||
REQUIRE_FALSE(totMem != prop.totalGlobalMem);
|
||||
|
||||
size_t free = 0, total = 0;
|
||||
HIP_CHECK(hipMemGetInfo(&free, &total));
|
||||
|
||||
REQUIRE(totMem == prop.totalGlobalMem);
|
||||
REQUIRE(total == totMem);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipDeviceTotalMem_NonSelectedDevice") {
|
||||
auto deviceCount = HipTest::getDeviceCount();
|
||||
if (deviceCount < 2) {
|
||||
HipTest::HIP_SKIP_TEST("Multi Device Test, will not run on single gpu systems. Skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 1; i < deviceCount; i++) {
|
||||
HIP_CHECK(hipSetDevice(i - 1));
|
||||
hipDevice_t device;
|
||||
HIP_CHECK(hipDeviceGet(&device, i));
|
||||
|
||||
size_t totMem = 0;
|
||||
hipDeviceProp_t prop;
|
||||
HIP_CHECK(hipDeviceTotalMem(&totMem, device));
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, device));
|
||||
REQUIRE(totMem == prop.totalGlobalMem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
Copyright (c) 2022 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>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
/**
|
||||
* 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 hipErrorInvalidValue for flags = nullptr.
|
||||
* Scenario2: Validates if hipSetDeviceFlags returns hipErrorInvalidValue for invalid flags.
|
||||
* Scenario3: Validates if flags returned by hipGetDeviceFlags are valid.
|
||||
* Scenario4: Validates that flags set with hipSetDeviceFlags can be retrieved with
|
||||
* hipGetDeviceFlags.
|
||||
* Scenario5: Validates that flags set with hipSetDeviceFlags can be retrieved on a seperate thread
|
||||
* with hipGetDeviceFlags.
|
||||
*/
|
||||
TEST_CASE("Unit_hipGetSetDeviceFlags_NullptrFlag") {
|
||||
// Scenario1
|
||||
HIP_CHECK_ERROR(hipGetDeviceFlags(nullptr), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGetSetDeviceFlags_InvalidFlag") {
|
||||
#if HT_AMD
|
||||
HipTest::HIP_SKIP_TEST("EXSWCPHIPT-115");
|
||||
return;
|
||||
#endif
|
||||
// Scenario2
|
||||
const unsigned int invalidFlag = GENERATE(0b011, // schedule flags should not overlap
|
||||
0b101, // schedule flags should not overlap
|
||||
0b110, // schedule flags should not overlap
|
||||
0b111, // schedule flags should not overlap
|
||||
0b100000, // out of bounds
|
||||
0xFFFF);
|
||||
CAPTURE(invalidFlag);
|
||||
HIP_CHECK_ERROR(hipSetDeviceFlags(invalidFlag), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
std::array<unsigned int, 16> getValidFlags() {
|
||||
constexpr std::array<unsigned int, 4> scheduleFlags{hipDeviceScheduleAuto, hipDeviceScheduleSpin,
|
||||
hipDeviceScheduleYield,
|
||||
hipDeviceScheduleBlockingSync};
|
||||
constexpr std::array<unsigned int, 2> hostMapFlags{0, hipDeviceMapHost};
|
||||
constexpr std::array<unsigned int, 2> localMemResizeFlags{0, 0x10}; // FIXME EXSWCPHIPT-110
|
||||
constexpr size_t size = scheduleFlags.size() * hostMapFlags.size() * localMemResizeFlags.size();
|
||||
std::array<unsigned int, size> validFlags;
|
||||
int i = 0;
|
||||
for (auto sf : scheduleFlags) {
|
||||
for (auto hf : hostMapFlags) {
|
||||
for (auto lf : localMemResizeFlags) {
|
||||
validFlags[i] = sf | hf | lf;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return validFlags;
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Unit_hipGetSetDeviceFlags_ValidFlag") {
|
||||
// Scenario3
|
||||
auto validFlags = getValidFlags();
|
||||
|
||||
unsigned int flag = 0;
|
||||
HIP_CHECK(hipGetDeviceFlags(&flag));
|
||||
REQUIRE(std::find(std::begin(validFlags), std::end(validFlags), flag) != std::end(validFlags));
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGetSetDeviceFlags_SetThenGet") {
|
||||
// Scenario4
|
||||
auto validFlags = getValidFlags();
|
||||
|
||||
auto devNo = GENERATE(range(0, HipTest::getDeviceCount()));
|
||||
HIP_CHECK(hipSetDevice(devNo));
|
||||
|
||||
const unsigned int flag = GENERATE_COPY(from_range(std::begin(validFlags), std::end(validFlags)));
|
||||
HIP_CHECK(hipSetDeviceFlags(flag));
|
||||
|
||||
unsigned int getFlag;
|
||||
HIP_CHECK(hipGetDeviceFlags(&getFlag));
|
||||
// flags other than hipDeviceSchedule* are ignore on the ROCm backend
|
||||
#if HT_NVIDIA
|
||||
// CUDA backend will sometimes set other flags
|
||||
getFlag = getFlag & hipDeviceScheduleMask;
|
||||
#endif
|
||||
REQUIRE((flag & hipDeviceScheduleMask) == getFlag);
|
||||
}
|
||||
|
||||
TEST_CASE("Unit_hipGetSetDeviceFlags_Threaded") {
|
||||
// Scenario5
|
||||
auto validFlags = getValidFlags();
|
||||
|
||||
auto devNo = GENERATE(range(0, HipTest::getDeviceCount()));
|
||||
HIP_CHECK(hipSetDevice(devNo));
|
||||
|
||||
std::mutex mut;
|
||||
std::condition_variable cv;
|
||||
bool ready = false; // required to avoid spurious wakeups
|
||||
|
||||
const unsigned int flag = GENERATE_COPY(from_range(std::begin(validFlags), std::end(validFlags)));
|
||||
std::thread test_thread([&mut, &ready, &cv, devNo, flag]() {
|
||||
std::unique_lock<std::mutex> lock(mut);
|
||||
cv.wait(lock, [&ready] { return ready; });
|
||||
unsigned int getFlag;
|
||||
HIP_CHECK_THREAD(hipSetDevice(devNo));
|
||||
HIP_CHECK_THREAD(hipGetDeviceFlags(&getFlag));
|
||||
// flags other than hipDeviceSchedule* are ignore on the ROCm backend
|
||||
#if HT_NVIDIA
|
||||
// CUDA backend will set other flags we aren't concerned about
|
||||
getFlag = getFlag & hipDeviceScheduleMask;
|
||||
#endif
|
||||
REQUIRE_THREAD((flag & hipDeviceScheduleMask) == getFlag);
|
||||
});
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mut);
|
||||
HIP_CHECK(hipSetDeviceFlags(flag));
|
||||
ready = true;
|
||||
}
|
||||
|
||||
cv.notify_one();
|
||||
|
||||
test_thread.join();
|
||||
HIP_CHECK_THREAD_FINALIZE();
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2021 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));
|
||||
}
|
||||
}
|
||||
@@ -87,5 +87,4 @@ static_cast<const float*>(A_d), static_cast<const float*>(B_d), C_d, N);
|
||||
HIP_CHECK(hipEventDestroy(stop));
|
||||
|
||||
HipTest::checkVectorADD(A_h, B_h, C_h, N, true);
|
||||
TestContext::get().cleanContext();
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ set(TEST_SRC
|
||||
hipDrvPtrGetAttributes.cc
|
||||
hipMallocMngdMultiThread.cc
|
||||
hipMemPrefetchAsync.cc
|
||||
hipArray.cc
|
||||
)
|
||||
else()
|
||||
set(TEST_SRC
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright (c) 2022 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>
|
||||
TEST_CASE("Unit_hipArray_Valid") {
|
||||
hipArray* array = nullptr;
|
||||
HIP_ARRAY_DESCRIPTOR desc;
|
||||
desc.Format = HIP_AD_FORMAT_FLOAT;
|
||||
desc.NumChannels = 1;
|
||||
desc.Width = 1024;
|
||||
desc.Height = 1024;
|
||||
HIP_CHECK(hipArrayCreate(&array, &desc));
|
||||
HIP_CHECK(hipFreeArray(array));
|
||||
}
|
||||
TEST_CASE("Unit_hipArray_Invalid") {
|
||||
void* data = malloc(sizeof(char));
|
||||
hipArray_t arrayPtr = static_cast<hipArray*>(data);
|
||||
REQUIRE(hipFreeArray(arrayPtr) == hipErrorContextIsDestroyed);
|
||||
free(data);
|
||||
}
|
||||
TEST_CASE("Unit_hipArray_Nullptr") {
|
||||
hipArray* array = nullptr;
|
||||
REQUIRE(hipFreeArray(array) == hipErrorInvalidValue);
|
||||
}
|
||||
TEST_CASE("Unit_hipArray_DoubleFree") {
|
||||
hipArray* array = nullptr;
|
||||
HIP_ARRAY_DESCRIPTOR desc;
|
||||
desc.Format = HIP_AD_FORMAT_FLOAT;
|
||||
desc.NumChannels = 1;
|
||||
desc.Width = 1024;
|
||||
desc.Height = 1024;
|
||||
HIP_CHECK(hipArrayCreate(&array, &desc));
|
||||
HIP_CHECK(hipFreeArray(array));
|
||||
REQUIRE(hipFreeArray(array) == hipErrorContextIsDestroyed);
|
||||
}
|
||||
TEST_CASE("Unit_hipArray_TrippleDestroy") {
|
||||
hipArray* array = nullptr;
|
||||
HIP_ARRAY_DESCRIPTOR desc;
|
||||
desc.Format = HIP_AD_FORMAT_FLOAT;
|
||||
desc.NumChannels = 1;
|
||||
desc.Width = 1024;
|
||||
desc.Height = 1024;
|
||||
HIP_CHECK(hipArrayCreate(&array, &desc));
|
||||
HIP_CHECK(hipArrayDestroy(array));
|
||||
REQUIRE(hipArrayDestroy(array) == hipErrorContextIsDestroyed);
|
||||
REQUIRE(hipArrayDestroy(array) == hipErrorContextIsDestroyed);
|
||||
}
|
||||
TEST_CASE("Unit_hipArray_DoubleNullptr") {
|
||||
hipArray* array = nullptr;
|
||||
REQUIRE(hipFreeArray(array) == hipErrorInvalidValue);
|
||||
REQUIRE(hipFreeArray(array) == hipErrorInvalidValue);
|
||||
}
|
||||
TEST_CASE("Unit_hipArray_DoubleInvalid") {
|
||||
void* data = malloc(sizeof(char));
|
||||
hipArray_t arrayPtr = static_cast<hipArray*>(data);
|
||||
REQUIRE(hipFreeArray(arrayPtr) == hipErrorContextIsDestroyed);
|
||||
REQUIRE(hipFreeArray(arrayPtr) == hipErrorContextIsDestroyed);
|
||||
free(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,6 @@ TEST_CASE("Unit_hipHostMalloc_Basic") {
|
||||
HIP_CHECK(hipHostFree(A_h));
|
||||
HIP_CHECK(hipHostFree(B_h));
|
||||
HIP_CHECK(hipHostFree(C_h));
|
||||
TestContext::get().cleanContext();
|
||||
}
|
||||
}
|
||||
/*
|
||||
@@ -182,7 +181,6 @@ TEST_CASE("Unit_hipHostMalloc_NonCoherent") {
|
||||
SYNC_STREAM, ptrType);
|
||||
CheckHostPointer(numElements, A, hipEventReleaseToSystem,
|
||||
SYNC_EVENT, ptrType);
|
||||
TestContext::get().cleanContext();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -122,10 +122,14 @@ TEST_CASE("Unit_hipPtrGetAttribute_Simple") {
|
||||
|
||||
// HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL
|
||||
if (numDevices > 1) {
|
||||
HIP_CHECK(hipSetDevice(1));
|
||||
HIP_CHECK(hipPointerGetAttribute(&datatype, HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL,
|
||||
reinterpret_cast<hipDeviceptr_t>(A_d)));
|
||||
REQUIRE(datatype == 0);
|
||||
int canAccess = -1;
|
||||
HIP_CHECK(hipDeviceCanAccessPeer(&canAccess, 1, 0));
|
||||
if (canAccess == 1) {
|
||||
HIP_CHECK(hipSetDevice(1));
|
||||
HIP_CHECK(hipPointerGetAttribute(&datatype, HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL,
|
||||
reinterpret_cast<hipDeviceptr_t>(A_d)));
|
||||
REQUIRE(datatype == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// HIP_POINTER_ATTRIBUTE_MAPPED
|
||||
|
||||
Yeni konuda referans
Bir kullanıcı engelle