Files
rocm-systems/rocrtst/suites/test_common/main.cc
T

569 lines
15 KiB
C++
Raw Normal View History

2017-07-28 10:27:51 -05:00
/*
* =============================================================================
* ROC Runtime Conformance Release License
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2017, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
*
* AMD Research and AMD ROC Software Development
*
* Advanced Micro Devices, Inc.
*
* www.amd.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with 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:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in
* the documentation and/or other materials provided with the distribution.
* - Neither the names of <Name of Development Group, Name of Institution>,
* nor the names of its contributors may be used to endorse or promote
* products derived from this Software without specific prior written
* permission.
*
* 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 CONTRIBUTORS 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 WITH THE SOFTWARE.
*
*/
#include <string>
#include <vector>
#include <memory>
#include "gtest/gtest.h"
#include "suites/functional/agent_props.h"
2018-04-25 13:36:46 -04:00
#include "suites/functional/debug_basic.h"
2017-07-31 12:04:55 -05:00
#include "suites/functional/memory_basic.h"
#include "suites/functional/memory_access.h"
2017-09-28 09:48:25 -05:00
#include "suites/functional/ipc.h"
#include "suites/functional/memory_alignment.h"
#include "suites/functional/memory_atomics.h"
#include "suites/functional/memory_allocation.h"
2019-06-26 04:13:52 -05:00
#include "suites/functional/deallocation_notifier.h"
2022-12-19 14:31:14 +00:00
#include "suites/functional/virtual_memory.h"
2017-07-28 10:27:51 -05:00
#include "suites/performance/dispatch_time.h"
#include "suites/performance/memory_async_copy.h"
2017-08-29 14:36:26 -05:00
#include "suites/performance/memory_async_copy_numa.h"
#include "suites/performance/enqueueLatency.h"
2018-04-19 16:14:27 +05:30
#include "suites/negative/memory_allocate_negative_tests.h"
#include "suites/negative/queue_validation.h"
#include "suites/stress/memory_concurrent_tests.h"
2018-05-23 15:39:56 +05:30
#include "suites/stress/queue_write_index_concurrent_tests.h"
2017-07-28 10:27:51 -05:00
#include "suites/test_common/test_case_template.h"
#include "suites/test_common/main.h"
#include "suites/test_common/test_common.h"
#include "suites/functional/concurrent_init.h"
#include "suites/functional/concurrent_init_shutdown.h"
#include "suites/functional/concurrent_shutdown.h"
#include "suites/functional/reference_count.h"
2018-05-28 14:44:39 +05:30
#include "suites/functional/signal_concurrent.h"
2018-05-31 15:29:37 +05:30
#include "suites/functional/aql_barrier_bit.h"
2018-05-31 21:38:21 +05:30
#include "suites/functional/signal_kernel.h"
2021-10-07 19:36:35 -05:00
#include "suites/functional/cu_masking.h"
2017-10-06 09:41:10 -05:00
#include "rocm_smi/rocm_smi.h"
2017-07-28 10:27:51 -05:00
static RocrTstGlobals *sRocrtstGlvalues = nullptr;
2017-07-31 12:04:55 -05:00
static void SetFlags(TestBase *test) {
2017-07-28 10:27:51 -05:00
assert(sRocrtstGlvalues != nullptr);
2017-08-29 14:36:26 -05:00
test->set_num_iteration(sRocrtstGlvalues->num_iterations);
2017-07-28 10:27:51 -05:00
test->set_verbosity(sRocrtstGlvalues->verbosity);
test->set_monitor_verbosity(sRocrtstGlvalues->monitor_verbosity);
2017-07-31 12:04:55 -05:00
}
static void RunCustomTestProlog(TestBase *test) {
SetFlags(test);
2017-07-28 10:27:51 -05:00
test->DisplayTestInfo();
test->SetUp();
test->Run();
2017-07-31 12:04:55 -05:00
return;
}
static void RunCustomTestEpilog(TestBase *test) {
2017-07-28 10:27:51 -05:00
test->DisplayResults();
test->Close();
2017-07-31 12:04:55 -05:00
return;
}
2017-07-28 10:27:51 -05:00
2017-07-31 12:04:55 -05:00
// If the test case one big test, you should use RunGenericTest()
// to run the test case. OTOH, if the test case consists of multiple
// functions to be run as separate tests, follow this pattern:
// * RunCustomTestProlog(test) // Run() should contain minimal code
// * <insert call to actual test function within test case>
// * RunCustomTestEpilog(test)
static void RunGenericTest(TestBase *test) {
RunCustomTestProlog(test);
RunCustomTestEpilog(test);
2017-07-28 10:27:51 -05:00
return;
}
// TEST ENTRY TEMPLATE:
// TEST(rocrtst, Perf_<test name>) {
// <Test Implementation class> <test_obj>;
//
2017-07-31 12:04:55 -05:00
// // Copy and modify implementation of RunGenericTest() if you need to deviate
2017-07-28 10:27:51 -05:00
// // from the standard pattern implemented there.
2017-07-31 12:04:55 -05:00
// RunGenericTest(&<test_obj>);
2017-07-28 10:27:51 -05:00
// }
TEST(rocrtst, Test_Example) {
TestExample tst;
2017-07-31 12:04:55 -05:00
RunGenericTest(&tst);
}
TEST(rocrtstFunc, MemoryAccessTests) {
MemoryAccessTest mt;
RunCustomTestProlog(&mt);
mt.CPUAccessToGPUMemoryTest();
mt.GPUAccessToCPUMemoryTest();
RunCustomTestEpilog(&mt);
}
2018-02-13 17:37:25 -06:00
TEST(rocrtstFunc, GroupMemoryAllocationTest) {
MemoryAllocationTest ma(true, false);
RunCustomTestProlog(&ma);
ma.GroupMemoryDynamicAllocation();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, MemoryAllocateAndFreeTest) {
MemoryAllocationTest ma(false, true);
RunCustomTestProlog(&ma);
ma.MemoryBasicAllocationAndFree();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, MemoryAllocateContiguousTest) {
MemoryAllocationTest ma(false, true);
RunCustomTestProlog(&ma);
ma.MemoryAllocateContiguousTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Concurrent_Init_Test) {
ConcurrentInitTest ci;
RunCustomTestProlog(&ci);
ci.TestConcurrentInit();
RunCustomTestEpilog(&ci);
}
TEST(rocrtstFunc, Concurrent_Init_Shutdown_Test) {
ConcurrentInitShutdownTest ci;
RunCustomTestProlog(&ci);
ci.TestConcurrentInitShutdown();
RunCustomTestEpilog(&ci);
}
TEST(rocrtstFunc, Concurrent_Shutdown) {
ConcurrentShutdownTest cs;
RunCustomTestProlog(&cs);
cs.TestConcurrentShutdown();
RunCustomTestEpilog(&cs);
}
TEST(rocrtstFunc, Reference_Count) {
ReferenceCountTest rc(true, false);
RunCustomTestProlog(&rc);
rc.TestReferenceCount();
RunCustomTestEpilog(&rc);
}
TEST(rocrtstFunc, Max_Reference_Count) {
ReferenceCountTest rc(false, true);
RunCustomTestProlog(&rc);
rc.TestMaxReferenceCount();
RunCustomTestEpilog(&rc);
}
2018-05-28 14:44:39 +05:30
TEST(rocrtstFunc, Signal_Destroy_Concurrently) {
SignalConcurrentTest sd(true, false, false, false);
RunCustomTestProlog(&sd);
sd.TestSignalDestroyConcurrent();
RunCustomTestEpilog(&sd);
}
TEST(rocrtstFunc, Signal_Max_Consumer) {
SignalConcurrentTest sd(false, true, false, false);
RunCustomTestProlog(&sd);
sd.TestSignalCreateMaxConsumers();
RunCustomTestEpilog(&sd);
}
TEST(rocrtstFunc, Signal_Create_Concurrently) {
SignalConcurrentTest sd(false, false, false, true);
RunCustomTestProlog(&sd);
sd.TestSignalCreateConcurrent();
RunCustomTestEpilog(&sd);
}
2022-07-15 11:23:16 -04:00
/* Temporary: Disable CU Masking until it is fixed */
TEST(rocrtstFunc, DISABLED_CU_Masking) {
2021-10-07 19:36:35 -05:00
CU_Masking sd;
RunGenericTest(&sd);
}
2018-06-03 15:13:48 -05:00
#ifndef ROCRTST_EMULATOR_BUILD
TEST(rocrtstFunc, IPC) {
IPCTest ipc;
RunGenericTest(&ipc);
}
2018-06-08 12:14:27 -05:00
TEST(rocrtstFunc, DISABLED_Signal_Kernel_Set) {
2018-05-31 21:38:21 +05:30
SignalKernelTest sk(SET);
RunCustomTestProlog(&sk);
sk.TestSignalKernelSet();
RunCustomTestEpilog(&sk);
}
2018-06-08 12:14:27 -05:00
TEST(rocrtstFunc, DISABLED_Signal_Kernel_Multi_Set) {
2018-05-31 21:38:21 +05:30
SignalKernelTest sk(MULTISET);
RunCustomTestProlog(&sk);
sk.TestSignalKernelMultiSet();
RunCustomTestEpilog(&sk);
}
2018-06-08 12:14:27 -05:00
TEST(rocrtstFunc, DISABLED_Signal_Kernel_Wait) {
2018-05-31 21:38:21 +05:30
SignalKernelTest sw(WAIT);
RunCustomTestProlog(&sw);
sw.TestSignalKernelWait();
RunCustomTestEpilog(&sw);
}
2018-06-08 12:14:27 -05:00
TEST(rocrtstFunc, DISABLED_Signal_Kernel_Multi_Wait) {
2018-05-31 21:38:21 +05:30
SignalKernelTest sw(MULTIWAIT);
RunCustomTestProlog(&sw);
sw.TestSignalKernelMultiWait();
RunCustomTestEpilog(&sw);
}
2018-06-01 16:03:18 -05:00
TEST(rocrtstFunc, DISABLED_Aql_Barrier_Bit_Set) {
2018-05-31 15:29:37 +05:30
AqlBarrierBitTest ab(true, false);
RunCustomTestProlog(&ab);
ab.BarrierBitSet();
RunCustomTestEpilog(&ab);
}
2018-06-01 16:03:18 -05:00
TEST(rocrtstFunc, DISABLED_Aql_Barrier_Bit_Not_Set) {
2018-05-31 15:29:37 +05:30
AqlBarrierBitTest ab(false, true);
RunCustomTestProlog(&ab);
ab.BarrierBitNotSet();
RunCustomTestEpilog(&ab);
}
2018-02-13 17:37:25 -06:00
TEST(rocrtstFunc, Memory_Max_Mem) {
2017-07-31 12:04:55 -05:00
MemoryTest mt;
RunCustomTestProlog(&mt);
mt.MaxSingleAllocationTest();
RunCustomTestEpilog(&mt);
2017-07-28 10:27:51 -05:00
}
2022-05-30 19:20:06 -04:00
TEST(rocrtstFunc, Memory_Available) {
MemoryTest mt;
RunCustomTestProlog(&mt);
mt.MemAvailableTest();
RunCustomTestEpilog(&mt);
}
TEST(rocrtstFunc, Memory_Atomic_Add_Test) {
MemoryAtomic ma(ADD);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_Sub_Test) {
MemoryAtomic ma(SUB);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_And_Test) {
MemoryAtomic ma(AND);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_Or_Test) {
MemoryAtomic ma(OR);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_Xor_Test) {
MemoryAtomic ma(XOR);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_Min_Test) {
MemoryAtomic ma(MIN);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_Max_Test) {
MemoryAtomic ma(MAX);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_Inc_Test) {
MemoryAtomic ma(INC);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_Dec_Test) {
MemoryAtomic ma(DEC);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
TEST(rocrtstFunc, Memory_Atomic_Xchg_Test) {
MemoryAtomic ma(XCHG);
RunCustomTestProlog(&ma);
ma.MemoryAtomicTest();
RunCustomTestEpilog(&ma);
}
2019-06-28 16:21:36 -05:00
TEST(rocrtstFunc, DISABLED_DebugBasicTests) {
2018-04-25 13:36:46 -04:00
DebugBasicTest mt;
RunCustomTestProlog(&mt);
mt.VectorAddDebugTrapTest();
RunCustomTestEpilog(&mt);
}
TEST(rocrtstFunc, Memory_Alignment_Test) {
MemoryAlignmentTest ma;
RunCustomTestProlog(&ma);
ma.MemoryPoolAlignment();
RunCustomTestEpilog(&ma);
}
2019-06-26 04:13:52 -05:00
TEST(rocrtstFunc, Deallocation_Notifier_Test) {
DeallocationNotifierTest notifier;
RunGenericTest(&notifier);
}
TEST(rocrtstFunc, AgentProp_UUID) {
AgentPropTest propTest;
RunCustomTestProlog(&propTest);
propTest.QueryAgentUUID();
RunCustomTestEpilog(&propTest);
}
2022-12-19 14:31:14 +00:00
TEST(rocrtstFunc, VirtMemory_Basic_Test) {
VirtMemoryTestBasic vmt;
RunCustomTestProlog(&vmt);
vmt.TestCreateDestroy();
vmt.TestRefCount();
vmt.TestPartialMapping();
2024-02-02 20:33:20 +00:00
RunCustomTestEpilog(&vmt);
}
TEST(rocrtstFunc, VirtMemory_Access_Test) {
VirtMemoryTestBasic vmt;
RunCustomTestProlog(&vmt);
2022-12-19 14:31:14 +00:00
vmt.CPUAccessToGPUMemoryTest();
vmt.GPUAccessToCPUMemoryTest();
2024-02-02 20:33:20 +00:00
vmt.GPUAccessToGPUMemoryTest();
2022-12-19 14:31:14 +00:00
RunCustomTestEpilog(&vmt);
}
2022-12-19 14:33:20 +00:00
TEST(rocrtstFunc, VirtMemory_Interprocess_Test) {
VirtMemoryTestInterProcess vmt;
RunCustomTestProlog(&vmt);
RunCustomTestEpilog(&vmt);
}
2018-04-19 16:14:27 +05:30
TEST(rocrtstNeg, Memory_Negative_Tests) {
MemoryAllocateNegativeTest mt;
RunCustomTestProlog(&mt);
mt.ZeroMemoryAllocateTest();
mt.MaxMemoryAllocateTest();
RunCustomTestEpilog(&mt);
}
TEST(rocrtstNeg, Queue_Validation_InvalidDimension) {
QueueValidation qv(true, false, false, false, false);
RunCustomTestProlog(&qv);
qv.QueueValidationForInvalidDimension();
RunCustomTestEpilog(&qv);
}
TEST(rocrtstNeg, Queue_Validation_InvalidGroupMemory) {
QueueValidation qv(false, true, false, false, false);
RunCustomTestProlog(&qv);
qv.QueueValidationInvalidGroupMemory();
RunCustomTestEpilog(&qv);
}
TEST(rocrtstNeg, Queue_Validation_InvalidKernelObject) {
QueueValidation qv(false, false, true, false, false);
RunCustomTestProlog(&qv);
qv.QueueValidationForInvalidKernelObject();
RunCustomTestEpilog(&qv);
}
TEST(rocrtstNeg, Queue_Validation_InvalidPacket) {
QueueValidation qv(false, false, false, true, false);
RunCustomTestProlog(&qv);
qv.QueueValidationForInvalidPacket();
RunCustomTestEpilog(&qv);
}
TEST(rocrtstNeg, DISABLED_Queue_Validation_InvalidWorkGroupSize) {
QueueValidation qv(false, false, false, false, true);
RunCustomTestProlog(&qv);
qv.QueueValidationForInvalidWorkGroupSize();
RunCustomTestEpilog(&qv);
}
TEST(rocrtstStress, Memory_Concurrent_Allocate_Test) {
MemoryConcurrentTest mt(true, false, false);
RunCustomTestProlog(&mt);
mt.MemoryConcurrentAllocate();
RunCustomTestEpilog(&mt);
}
TEST(rocrtstStress, Memory_Concurrent_Free_Test) {
MemoryConcurrentTest mt(false, true, false);
RunCustomTestProlog(&mt);
mt.MemoryConcurrentFree();
RunCustomTestEpilog(&mt);
}
TEST(rocrtstStress, Memory_Concurrent_Pool_Info_Test) {
MemoryConcurrentTest mt(false, false, true);
RunCustomTestProlog(&mt);
mt.MemoryConcurrentPoolGetInfo();
RunCustomTestEpilog(&mt);
}
2018-05-23 15:39:56 +05:30
TEST(rocrtstStress, Queue_Add_Write_Index_ConcurrentTest) {
QueueWriteIndexConcurrentTest Qw(true, false, false);
RunCustomTestProlog(&Qw);
Qw.QueueAddWriteIndexAtomic();
RunCustomTestEpilog(&Qw);
}
TEST(rocrtstStress, Queue_CAS_Write_Index_ConcurrentTest) {
QueueWriteIndexConcurrentTest Qw(false, true, false);
RunCustomTestProlog(&Qw);
Qw.QueueCasWriteIndexAtomic();
RunCustomTestEpilog(&Qw);
}
TEST(rocrtstStress, Queue_LoadStore_Write_Index_ConcurrentTest) {
QueueWriteIndexConcurrentTest Qw(false, false, true);
RunCustomTestProlog(&Qw);
Qw.QueueLoadStoreWriteIndexAtomic();
RunCustomTestEpilog(&Qw);
}
2017-07-28 10:27:51 -05:00
TEST(rocrtstPerf, Memory_Async_Copy) {
MemoryAsyncCopy mac;
// To do full test, uncomment this:
// mac.set_full_test(true);
// To test only 1 path, add lines like this:
// mac.set_src_pool(<src pool id>);
// mac.set_dst_pool(<dst pool id>);
// The default is to and from the cpu to 1 gpu, and to/from a gpu to
// another gpu
2017-07-31 12:04:55 -05:00
RunGenericTest(&mac);
2017-07-28 10:27:51 -05:00
}
2018-06-07 14:31:51 -05:00
#endif // ROCRTST_EMULATOR_BUILD
TEST(rocrtstPerf, ENQUEUE_LATENCY) {
EnqueueLatency singlePacketequeue(true);
EnqueueLatency multiPacketequeue(false);
RunGenericTest(&singlePacketequeue);
RunGenericTest(&multiPacketequeue);
}
2017-07-28 10:27:51 -05:00
TEST(rocrtstPerf, DISABLED_Memory_Async_Copy_NUMA) {
2017-08-29 14:36:26 -05:00
MemoryAsyncCopyNUMA numa;
RunGenericTest(&numa);
}
TEST(rocrtstPerf, AQL_Dispatch_Time_Single_SpinWait) {
2017-07-28 10:27:51 -05:00
DispatchTime dt(true, true);
2017-07-31 12:04:55 -05:00
RunGenericTest(&dt);
2017-07-28 10:27:51 -05:00
}
TEST(rocrtstPerf, AQL_Dispatch_Time_Single_Interrupt) {
2017-07-28 10:27:51 -05:00
DispatchTime dt(false, true);
2017-07-31 12:04:55 -05:00
RunGenericTest(&dt);
2017-07-28 10:27:51 -05:00
}
TEST(rocrtstPerf, AQL_Dispatch_Time_Multi_SpinWait) {
2017-07-28 10:27:51 -05:00
DispatchTime dt(true, false);
2017-07-31 12:04:55 -05:00
RunGenericTest(&dt);
2017-07-28 10:27:51 -05:00
}
TEST(rocrtstPerf, AQL_Dispatch_Time_Multi_Interrupt) {
2017-07-28 10:27:51 -05:00
DispatchTime dt(false, false);
2017-07-31 12:04:55 -05:00
RunGenericTest(&dt);
2017-07-28 10:27:51 -05:00
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
2021-08-13 16:46:26 -05:00
#ifdef ROCRTST_EMULATOR_BUILD
std::cout << "--- Emulation build ---" << std::endl;
#endif
2017-07-28 10:27:51 -05:00
RocrTstGlobals settings;
// Set some default values
2017-07-28 10:27:51 -05:00
settings.verbosity = 1;
settings.monitor_verbosity = 0;
settings.num_iterations = 5;
2017-07-28 10:27:51 -05:00
if (ProcessCmdline(&settings, argc, argv)) {
return 1;
}
sRocrtstGlvalues = &settings;
if (settings.monitor_verbosity > 0) {
rsmi_status_t rsmi_ret = rsmi_init(0);
if (rsmi_ret != RSMI_STATUS_SUCCESS) {
std::cout << "Failed to initialize ROCm smi" << std::endl;
return 1;
}
DumpMonitorInfo();
}
2017-07-28 10:27:51 -05:00
return RUN_ALL_TESTS();
}