Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

215 wiersze
6.3 KiB
C++

2024-07-01 09:57:08 -05:00
/******************************************************************************
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
* SPDX-License-Identifier: MIT
2024-07-01 09:57:08 -05:00
*
* 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
2024-07-01 09:57:08 -05:00
* 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.
*****************************************************************************/
#ifndef _TESTER_HPP_
#define _TESTER_HPP_
2024-11-25 14:12:15 -06:00
#include <rocshmem/rocshmem.hpp>
2024-07-01 09:57:08 -05:00
#include <vector>
2025-02-17 06:18:46 +00:00
#include <climits>
2024-07-01 09:57:08 -05:00
#include "tester_arguments.hpp"
2025-02-17 06:18:46 +00:00
#include "../src/util.hpp"
#include "verify_results_kernels.hpp"
2024-07-01 09:57:08 -05:00
/******************************************************************************
* TESTER CLASS TYPES
*****************************************************************************/
enum TestType {
GetTestType = 0,
GetNBITestType = 1,
PutTestType = 2,
PutNBITestType = 3,
2025-03-18 14:39:57 -05:00
AMO_FAddTestType = 4,
AMO_FIncTestType = 5,
AMO_FetchTestType = 6,
AMO_FCswapTestType = 7,
AMO_AddTestType = 8,
AMO_IncTestType = 9,
AMO_CswapTestType = 10,
InitTestType = 11,
PingPongTestType = 12,
RandomAccessTestType = 13,
BarrierAllTestType = 14,
SyncAllTestType = 15,
2025-10-23 13:40:41 -04:00
TeamSyncTestType = 16,
2025-03-18 14:39:57 -05:00
CollectTestType = 17,
TeamFCollectTestType = 18,
TeamAllToAllTestType = 19,
AllToAllsTestType = 20,
ShmemPtrTestType = 21,
PTestType = 22,
GTestType = 23,
WGGetTestType = 24,
WGGetNBITestType = 25,
WGPutTestType = 26,
WGPutNBITestType = 27,
WAVEGetTestType = 28,
WAVEGetNBITestType = 29,
WAVEPutTestType = 30,
WAVEPutNBITestType = 31,
TeamBroadcastTestType = 32,
TeamReductionTestType = 33,
TeamCtxGetTestType = 34,
TeamCtxGetNBITestType = 35,
TeamCtxPutTestType = 36,
TeamCtxPutNBITestType = 37,
TeamCtxInfraTestType = 38,
PutNBIMRTestType = 39,
AMO_SetTestType = 40,
AMO_SwapTestType = 41,
AMO_FetchAndTestType = 42,
AMO_FetchOrTestType = 43,
AMO_FetchXorTestType = 44,
AMO_AndTestType = 45,
AMO_OrTestType = 46,
AMO_XorTestType = 47,
PingAllTestType = 48,
PutSignalTestType = 49,
WGPutSignalTestType = 50,
WAVEPutSignalTestType = 51,
PutSignalNBITestType = 52,
WGPutSignalNBITestType = 53,
WAVEPutSignalNBITestType = 54,
SignalFetchTestType = 55,
WGSignalFetchTestType = 56,
WAVESignalFetchTestType = 57,
2025-04-08 11:25:31 -05:00
TeamWGBarrierTestType = 58,
2025-03-25 18:51:54 -05:00
DefaultCTXGetTestType = 59,
DefaultCTXGetNBITestType = 60,
DefaultCTXPutTestType = 61,
DefaultCTXPutNBITestType = 62,
DefaultCTXPTestType = 63,
DefaultCTXGTestType = 64,
2025-04-02 11:58:55 -05:00
WAVEBarrierAllTestType = 65,
WGBarrierAllTestType = 66,
WAVESyncAllTestType = 67,
WGSyncAllTestType = 68,
2025-04-08 11:25:31 -05:00
TeamBarrierTestType = 69,
TeamWAVEBarrierTestType = 70,
2025-10-23 13:40:41 -04:00
TeamWAVESyncTestType = 71,
TeamWGSyncTestType = 72,
2025-08-01 08:50:14 -05:00
TeamCtxInfraTestSingleType = 73,
TeamCtxInfraTestBlockType = 74,
TeamCtxInfraTestOddEvenType = 75,
TeamAlltoallmemOnStreamTestType = 76,
BarrierAllOnStreamTestType = 77,
TeamBroadcastmemOnStreamTestType = 78,
GetmemOnStreamTestType = 79,
PutmemOnStreamTestType = 80,
PutmemSignalOnStreamTestType = 81,
SignalWaitUntilOnStreamTestType = 82,
FloodPutTestType = 83,
FloodPutNBITestType = 84,
FloodPTestType = 85,
FloodGetTestType = 86,
FloodGetNBITestType = 87,
FloodGTestType = 88,
2024-07-01 09:57:08 -05:00
};
enum OpType { PutType = 0, GetType = 1 };
typedef int ShmemContextType;
/******************************************************************************
* TESTER INTERFACE
*****************************************************************************/
class Tester {
public:
explicit Tester(TesterArguments args);
virtual ~Tester();
void execute();
static std::vector<Tester *> create(TesterArguments args);
protected:
virtual void resetBuffers(uint64_t size) = 0;
virtual void preLaunchKernel() {}
virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop,
uint64_t size) = 0;
virtual void postLaunchKernel() {}
virtual void verifyResults(uint64_t size) = 0;
int num_msgs = 0;
int num_timed_msgs = 0;
int num_warps = 0;
2024-07-01 09:57:08 -05:00
int bw_factor = 1;
int device_id = 0;
2025-02-17 06:18:46 +00:00
int wall_clk_rate = 0; //in kilohertz
int wf_size = 0;
2024-07-01 09:57:08 -05:00
TesterArguments args;
TestType _type;
ShmemContextType _shmem_context = 8; // SHMEM_CTX_WP_PRIVATE
hipStream_t stream;
hipDeviceProp_t deviceProps;
2024-07-01 09:57:08 -05:00
2025-02-17 06:18:46 +00:00
long long int *timer = nullptr;
long long int *start_time = nullptr;
long long int *end_time = nullptr;
long long int min_start_time = 0;
long long int max_end_time = 0;
uint32_t num_timers = 0;
2024-07-01 09:57:08 -05:00
bool *verification_error;
protected:
bool _print_results = true;
2024-07-01 09:57:08 -05:00
private:
bool _print_header = true;
2024-07-01 09:57:08 -05:00
void print(uint64_t size);
void barrier();
2025-02-17 06:18:46 +00:00
double gpuCyclesToMicroseconds(long long int cycles);
2024-07-01 09:57:08 -05:00
2025-02-17 06:18:46 +00:00
double timerAvgInMicroseconds();
2024-07-01 09:57:08 -05:00
bool peLaunchesKernel();
hipEvent_t start_event;
hipEvent_t stop_event;
};
2025-09-05 12:21:18 -04:00
//TODO remove altogether? THere is a small difference in print format
#undef CHECK_HIP
#define CHECK_HIP(instr) do { \
hipError_t error = (instr); \
if (error != hipSuccess) { \
fprintf(stderr, "error: " #instr ": %s (%d) at %s:%d\n", \
hipGetErrorString(error), error, __FILE__, __LINE__); \
abort(); \
} \
} while(0)
2024-07-02 10:07:43 -07:00
2024-07-01 09:57:08 -05:00
#endif /* _TESTER_HPP */