Files
rocm-systems/perftests/memory/hipPerfMemcpy.cpp
T
TomSang bfc2f4516a SWDEV-299773 - Enable performance tests on NV (#2337)
1. Simply enable test on NV
   Some need minor fix
performance/compute/hipPerfDotProduct.cpp
performance/dispatch/hipPerfDispatchSpeed.cpp
performance/memory/hipPerfBufferCopyRectSpeed.cpp
performance/memory/hipPerfBufferCopySpeed.cpp
performance/memory/hipPerfDevMemReadSpeed.cpp
performance/memory/hipPerfDevMemWriteSpeed.cpp
performance/memory/hipPerfMemcpy.cpp
performance/memory/hipPerfMemset.cpp
performance/memory/hipPerfSharedMemReadSpeed.cpp
performance/stream/hipPerfDeviceConcurrency.cpp
performance/stream/hipPerfStreamCreateCopyDestroy.cpp

2. Enable and fix on NV
performance/compute/hipPerfMandelbrot.cpp
   Root cause: coordIdx is random
   Solution: Initialize coordIdx correctly
performance/memory/hipPerfMemFill.cpp
   Root cause: Hip ext Apis called.
   Solution: Exclude case with Hip ext Apis involved
performance/memory/hipPerfMemMallocCpyFree.cpp
   Root cause: Test allocates device memory more than GPU has.
   Solution: Allocate device memory in terms of GPU capacity.
tests/performance/memory/hipPerfSampleRate.cpp
   Root cause: Cuda has no operators += for float2 and float4.
   Solution: Provide the operators.
performance/stream/hipPerfStreamConcurrency.cpp
   Root cause:float4 format doesn't match cude.
              operators are missing in cuda lib.
   Solution: Use (x, y, z, w) format.
             Add necessary float4 operatoris for cuda.

Change-Id: I5add29ebabcfb21fb3ef89d09004c5d13423a291
2021-09-14 13:37:13 +05:30

115 righe
3.2 KiB
C++

/*
Copyright (c) 2015 - 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.
*/
/* HIT_START
* BUILD: %t %s ../../src/test_common.cpp
* TEST: %t
* HIT_END
*/
#include "test_common.h"
#include <iostream>
#include <chrono>
#define NUM_SIZE 8
#define NUM_ITER 0x40000
using namespace std;
class hipPerfMemcpy {
private:
unsigned int numBuffers_;
size_t totalSizes_[NUM_SIZE];
void setHostBuffer(int *A, int val, size_t size);
public:
hipPerfMemcpy();
~hipPerfMemcpy() {};
void open(int deviceID);
void run(unsigned int testNumber);
};
hipPerfMemcpy::hipPerfMemcpy() : numBuffers_(0) {
for (int i = 0; i < NUM_SIZE; i++) {
totalSizes_[i] = 1 << (i + 6);
}
};
void hipPerfMemcpy::setHostBuffer(int *A, int val, size_t size) {
size_t len = size / sizeof(int);
for (int i = 0; i < len; i++) {
A[i] = val;
}
}
void hipPerfMemcpy::open(int deviceId) {
int nGpu = 0;
HIPCHECK(hipGetDeviceCount(&nGpu));
if (nGpu < 1) {
failed("No GPU!");
}
HIPCHECK(hipSetDevice(deviceId));
hipDeviceProp_t props = {0};
HIPCHECK(hipGetDeviceProperties(&props, deviceId));
std::cout << "info: running on bus " << "0x" << props.pciBusID << " " << props.name
<< " with " << props.multiProcessorCount << " CUs" << " and device id: " << deviceId << std::endl;
}
void hipPerfMemcpy::run(unsigned int testNumber) {
int *A, *Ad;
A = new int[totalSizes_[testNumber]];
setHostBuffer(A, 1, totalSizes_[testNumber]);
hipMalloc(&Ad, totalSizes_[testNumber]);
auto start = chrono::steady_clock::now();
for (int j = 0; j < NUM_ITER; j++) {
hipMemcpy(Ad, A, totalSizes_[testNumber], hipMemcpyHostToDevice);
}
hipDeviceSynchronize();
auto end = chrono::steady_clock::now();
chrono::duration<double, micro> diff = end - start;
cout << "hipPerfMemcpy[" << testNumber << "] " << "Host to Device copy took "
<< diff.count() / NUM_ITER << " us for memory size of " << totalSizes_[testNumber]
<< " Bytes" << endl;
delete [] A;
HIPCHECK(hipFree(Ad));
}
int main() {
hipPerfMemcpy hipPerfMemcpy;
int deviceId = 0;
hipPerfMemcpy.open(deviceId);
for (auto testCase = 0; testCase < NUM_SIZE; testCase++) {
hipPerfMemcpy.run(testCase);
}
passed();
}