SWDEV-1 - Merge github PRs to amd-staging
- https://github.com/ROCm/hip-tests/pull/119 - https://github.com/ROCm/hip-tests/pull/151 - https://github.com/ROCm/hip-tests/pull/57 - https://github.com/ROCm/hip-tests/pull/58 - https://github.com/ROCm/hip-tests/pull/59 - https://github.com/ROCm/hip-tests/pull/60 - https://github.com/ROCm/hip-tests/pull/99 - https://github.com/ROCm/hip-tests/pull/139 - https://github.com/ROCm/hip-tests/pull/152 - https://github.com/ROCm/hip-tests/pull/48 - https://github.com/ROCm/hip-tests/pull/54 - https://github.com/ROCm/hip-tests/pull/53 - https://github.com/ROCm/hip-tests/pull/24 - https://github.com/ROCm/hip-tests/pull/23 - https://github.com/ROCm/hip-tests/pull/22 - https://github.com/ROCm/hip-tests/pull/21 - https://github.com/ROCm/hip-tests/pull/20 - https://github.com/ROCm/hip-tests/pull/14 - https://github.com/ROCm/hip-tests/pull/8 Change-Id: I1eea54cd1436f3ddbfd5c1b3b2f672eb81d03cd4
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Copyright (c) 2024 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 "memcpy_performance_common.hh"
|
||||
#pragma clang diagnostic ignored "-Wvla-extension"
|
||||
|
||||
/**
|
||||
* @addtogroup memcpy memcpy
|
||||
* @{
|
||||
* @ingroup PerformanceTest
|
||||
*/
|
||||
|
||||
__device__ int devSymbol[1_MB];
|
||||
|
||||
class MemcpyToSymbolAsyncBenchmark : public Benchmark<MemcpyToSymbolAsyncBenchmark> {
|
||||
public:
|
||||
void operator()(const void* source, size_t size, size_t offset, const hipStream_t& stream) {
|
||||
TIMED_SECTION_STREAM(kTimerTypeEvent, stream) {
|
||||
HIP_CHECK(hipMemcpyToSymbolAsync(HIP_SYMBOL(devSymbol), source, size, offset,
|
||||
hipMemcpyHostToDevice, stream));
|
||||
}
|
||||
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
}
|
||||
};
|
||||
|
||||
static void RunBenchmark(const void* source, size_t size=1, size_t offset=0) {
|
||||
MemcpyToSymbolAsyncBenchmark benchmark;
|
||||
benchmark.AddSectionName(std::to_string(size));
|
||||
benchmark.AddSectionName(std::to_string(offset));
|
||||
|
||||
const StreamGuard stream_guard(Streams::created);
|
||||
const hipStream_t stream = stream_guard.stream();
|
||||
benchmark.Run(source, size, offset, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Executes `hipMemcpyToSymbolAsync` from Host to Device.
|
||||
* - Utilizes sigular integer values.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - performance/memcpy/hipMemcpyToSymbolAsync.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.2
|
||||
*/
|
||||
TEST_CASE("Performance_hipMemcpyToSymbolAsync_SingularValue") {
|
||||
int set{42};
|
||||
RunBenchmark(&set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Executes `hipMemcpyToSymbolAsync` from Host to Device.
|
||||
* - Utilizes array integers:
|
||||
* - Small: 1 KB
|
||||
* - Medium: 4 KB
|
||||
* - Large: 1 MB
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - performance/memcpy/hipMemcpyToSymbolAsync.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.2
|
||||
*/
|
||||
TEST_CASE("Performance_hipMemcpyToSymbolAsync_ArrayValue") {
|
||||
size_t size = GENERATE(1_KB, 4_KB, 1_MB);
|
||||
std::vector<int> array(size);
|
||||
std::fill_n(array.data(), size, 42);
|
||||
|
||||
RunBenchmark(array.data(), sizeof(int) * size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Executes `hipMemcpyToSymbolAsync` from Host to Device.
|
||||
* - Utilizes array integers with offsets:
|
||||
* - Small: 1 KB
|
||||
* - Medium: 4 KB
|
||||
* - Large: 1 MB
|
||||
* - Offset: 0 and size/2
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - performance/memcpy/hipMemcpyToSymbolAsync.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.2
|
||||
*/
|
||||
TEST_CASE("Performance_hipMemcpyToSymbolAsync_WithOffset") {
|
||||
size_t size = GENERATE(1_KB, 4_KB, 1_MB);
|
||||
std::vector<int> array(size);
|
||||
std::fill_n(array.data(), size, 42);
|
||||
|
||||
size_t offset = GENERATE_REF(0, size / 2);
|
||||
RunBenchmark(array.data() + offset, sizeof(int) * (size - offset), offset * sizeof(int));
|
||||
}
|
||||
Fai riferimento in un nuovo problema
Block a user