EXSWHTEC-248 - Implement Performance Tests for Memset APIs #99

Change-Id: I6b4a0758299b0fd6d70c75508a4a0d67c62187ff
Tento commit je obsažen v:
Mirza Halilčević
2023-12-28 18:26:22 +01:00
odevzdal Rakesh Roy
rodič 2be6860916
revize 95a954e63a
14 změnil soubory, kde provedl 983 přidání a 0 odebrání
+7
Zobrazit soubor
@@ -173,6 +173,13 @@ THE SOFTWARE.
* @}
*/
/**
* @defgroup PerformanceTest Performance tests
* @{
* This section describes performance tests for the target API groups and use-cases.
* @}
*/
/**
* @defgroup TextureTest Texture Management
* @{
+39
Zobrazit soubor
@@ -0,0 +1,39 @@
# 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.
set(TEST_SRC
hipMemset.cc
hipMemsetAsync.cc
hipMemsetD8.cc
hipMemsetD8Async.cc
hipMemsetD16.cc
hipMemsetD16Async.cc
hipMemsetD32.cc
hipMemsetD32Async.cc
hipMemset2D.cc
hipMemset2DAsync.cc
hipMemset3D.cc
hipMemset3DAsync.cc
)
hip_add_exe_to_target(NAME MemsetPerformance
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests
COMPILE_OPTIONS -std=c++17)
+79
Zobrazit soubor
@@ -0,0 +1,79 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
* Contains performance tests for all memset HIP APIs.
*/
class MemsetBenchmark : public Benchmark<MemsetBenchmark> {
public:
MemsetBenchmark(LinearAllocs allocation_type, size_t size)
: dst_(allocation_type, size), size_(size) {}
void operator()() {
TIMED_SECTION(kTimerTypeEvent) { HIP_CHECK(hipMemset(dst_.ptr(), 17, size_)); }
}
private:
LinearAllocGuard<void> dst_;
const size_t size_;
};
static void RunBenchmark(LinearAllocs allocation_type, size_t size) {
MemsetBenchmark benchmark(allocation_type, size);
benchmark.AddSectionName(std::to_string(size));
benchmark.AddSectionName(GetAllocationSectionName(allocation_type));
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemset`:
* -# Allocation size
* - Small: 4 KB
* - Medium: 4 MB
* - Large: 16 MB
* -# Allocation type
* - device
* - host
* - managed
* Test source
* ------------------------
* - performance/memset/hipMemset.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemset") {
const auto size = GENERATE(4_KB, 4_MB, 16_MB);
const auto allocation_type = GENERATE(LinearAllocs::hipMalloc, LinearAllocs::hipHostMalloc,
LinearAllocs::hipMallocManaged);
RunBenchmark(allocation_type, size);
}
+71
Zobrazit soubor
@@ -0,0 +1,71 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class Memset2DBenchmark : public Benchmark<Memset2DBenchmark> {
public:
Memset2DBenchmark(size_t width, size_t height) : dst_(width, height) {}
void operator()() {
TIMED_SECTION(kTimerTypeEvent) {
HIP_CHECK(hipMemset2D(dst_.ptr(), dst_.pitch(), 17, dst_.width(), dst_.height()));
}
}
private:
LinearAllocGuard2D<char> dst_;
};
static void RunBenchmark(size_t width, size_t height) {
Memset2DBenchmark benchmark(width, height);
benchmark.AddSectionName("(" + std::to_string(width) + ", " + std::to_string(height) + ")");
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemset2D`:
* -# Allocation size
* - Small: 4 KB x 32 B
* - Medium: 4 MB x 32 B
* - Large: 16 MB x 32 B
* Test source
* ------------------------
* - performance/memset/hipMemset2D.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemset2D") {
const auto width = GENERATE(4_KB, 4_MB, 16_MB);
RunBenchmark(width, 32);
}
+74
Zobrazit soubor
@@ -0,0 +1,74 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class Memset2DAsyncBenchmark : public Benchmark<Memset2DAsyncBenchmark> {
public:
Memset2DAsyncBenchmark(size_t width, size_t height)
: dst_(width, height), stream_(Streams::created) {}
void operator()(size_t width, size_t height) {
TIMED_SECTION_STREAM(kTimerTypeEvent, stream_.stream()) {
HIP_CHECK(hipMemset2DAsync(dst_.ptr(), dst_.pitch(), 17, dst_.width(), dst_.height(),
stream_.stream()));
}
}
private:
LinearAllocGuard2D<char> dst_;
StreamGuard stream_;
};
static void RunBenchmark(size_t width, size_t height) {
Memset2DAsyncBenchmark benchmark(width, height);
benchmark.AddSectionName("(" + std::to_string(width) + ", " + std::to_string(height) + ")");
benchmark.Run(width, height);
}
/**
* Test Description
* ------------------------
* - Executes `hipMemset2DAsync`:
* -# Allocation size
* - Small: 4 KB x 32 B
* - Medium: 4 MB x 32 B
* - Large: 16 MB x 32 B
* Test source
* ------------------------
* - performance/memset/hipMemset2DAsync.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemset2DAsync") {
const auto width = GENERATE(4_KB, 4_MB, 16_MB);
RunBenchmark(width, 32);
}
+72
Zobrazit soubor
@@ -0,0 +1,72 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class Memset3DBenchmark : public Benchmark<Memset3DBenchmark> {
public:
Memset3DBenchmark(size_t width, size_t height, size_t depth) : dst_(width, height, depth) {}
void operator()() {
TIMED_SECTION(kTimerTypeEvent) {
HIP_CHECK(hipMemset3D(dst_.pitched_ptr(), 17, dst_.extent()));
}
}
private:
LinearAllocGuard3D<char> dst_;
};
static void RunBenchmark(size_t width, size_t height, size_t depth) {
Memset3DBenchmark benchmark(width, height, depth);
benchmark.AddSectionName("(" + std::to_string(width) + ", " + std::to_string(height) + ", " +
std::to_string(depth) + ")");
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemset3D`:
* -# Allocation size
* - Small: 4 KB x 16 B x 4 B
* - Medium: 4 MB x 16 B x 4 B
* - Large: 16 MB x 16 B x 4 B
* Test source
* ------------------------
* - performance/memset/hipMemset3D.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemset3D") {
const auto width = GENERATE(4_KB, 4_MB, 16_MB);
RunBenchmark(width, 16, 4);
}
+74
Zobrazit soubor
@@ -0,0 +1,74 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class Memset3DAsyncBenchmark : public Benchmark<Memset3DAsyncBenchmark> {
public:
Memset3DAsyncBenchmark(size_t width, size_t height, size_t depth)
: dst_(width, height, depth), stream_(Streams::created) {}
void operator()() {
TIMED_SECTION_STREAM(kTimerTypeEvent, stream_.stream()) {
HIP_CHECK(hipMemset3DAsync(dst_.pitched_ptr(), 17, dst_.extent(), stream_.stream()));
}
}
private:
LinearAllocGuard3D<char> dst_;
StreamGuard stream_;
};
static void RunBenchmark(size_t width, size_t height, size_t depth) {
Memset3DAsyncBenchmark benchmark(width, height, depth);
benchmark.AddSectionName("(" + std::to_string(width) + ", " + std::to_string(height) + ", " +
std::to_string(depth) + ")");
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemset3DAsync`:
* -# Allocation size
* - Small: 4 KB x 16 B x 4 B
* - Medium: 4 MB x 16 B x 4 B
* - Large: 16 MB x 16 B x 4 B
* Test source
* ------------------------
* - performance/memset/hipMemset3DAsync.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemset3DAsync") {
const auto width = GENERATE(4_KB, 4_MB, 16_MB);
RunBenchmark(width, 16, 4);
}
+81
Zobrazit soubor
@@ -0,0 +1,81 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class MemsetAsyncBenchmark : public Benchmark<MemsetAsyncBenchmark> {
public:
MemsetAsyncBenchmark(LinearAllocs allocation_type, size_t size)
: dst_(allocation_type, size), size_(size), stream_(Streams::created) {}
void operator()() {
TIMED_SECTION_STREAM(kTimerTypeEvent, stream_.stream()) {
HIP_CHECK(hipMemsetAsync(dst_.ptr(), 17, size_, stream_.stream()));
}
}
private:
LinearAllocGuard<void> dst_;
const size_t size_;
StreamGuard stream_;
};
static void RunBenchmark(LinearAllocs allocation_type, size_t size) {
MemsetAsyncBenchmark benchmark(allocation_type, size);
benchmark.AddSectionName(std::to_string(size));
benchmark.AddSectionName(GetAllocationSectionName(allocation_type));
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemsetAsync`:
* -# Allocation size
* - Small: 4 KB
* - Medium: 4 MB
* - Large: 16 MB
* -# Allocation type
* - device
* - host
* - managed
* Test source
* ------------------------
* - performance/memset/hipMemsetAsync.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemsetAsync") {
const auto size = GENERATE(4_KB, 4_MB, 16_MB);
const auto allocation_type = GENERATE(LinearAllocs::hipMalloc, LinearAllocs::hipHostMalloc,
LinearAllocs::hipMallocManaged);
RunBenchmark(allocation_type, size);
}
+80
Zobrazit soubor
@@ -0,0 +1,80 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class MemsetD16Benchmark : public Benchmark<MemsetD16Benchmark> {
public:
MemsetD16Benchmark(LinearAllocs allocation_type, size_t size)
: dst_(allocation_type, size), size_(size) {}
void operator()() {
TIMED_SECTION(kTimerTypeEvent) {
HIP_CHECK(hipMemsetD16(reinterpret_cast<hipDeviceptr_t>(dst_.ptr()), 311, size_));
}
}
private:
LinearAllocGuard<void> dst_;
const size_t size_;
};
static void RunBenchmark(LinearAllocs allocation_type, size_t size) {
MemsetD16Benchmark benchmark(allocation_type, size);
benchmark.AddSectionName(std::to_string(size));
benchmark.AddSectionName(GetAllocationSectionName(allocation_type));
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemsetD16`:
* -# Allocation size
* - Small: 4 KB
* - Medium: 4 MB
* - Large: 16 MB
* -# Allocation type
* - device
* - host
* - managed
* Test source
* ------------------------
* - performance/memset/hipMemsetD16.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemsetD16") {
const auto size = GENERATE(4_KB, 4_MB, 16_MB);
const auto allocation_type = GENERATE(LinearAllocs::hipMalloc, LinearAllocs::hipHostMalloc,
LinearAllocs::hipMallocManaged);
RunBenchmark(allocation_type, size);
}
+82
Zobrazit soubor
@@ -0,0 +1,82 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class MemsetD16AsyncBenchmark : public Benchmark<MemsetD16AsyncBenchmark> {
public:
MemsetD16AsyncBenchmark(LinearAllocs allocation_type, size_t size)
: dst_(allocation_type, size), size_(size), stream_(Streams::created) {}
void operator()() {
TIMED_SECTION_STREAM(kTimerTypeEvent, stream_.stream()) {
HIP_CHECK(hipMemsetD16Async(reinterpret_cast<hipDeviceptr_t>(dst_.ptr()), 311, size_,
stream_.stream()));
}
}
private:
LinearAllocGuard<void> dst_;
const size_t size_;
StreamGuard stream_;
};
static void RunBenchmark(LinearAllocs allocation_type, size_t size) {
MemsetD16AsyncBenchmark benchmark(allocation_type, size);
benchmark.AddSectionName(std::to_string(size));
benchmark.AddSectionName(GetAllocationSectionName(allocation_type));
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemsetD16Async`:
* -# Allocation size
* - Small: 4 KB
* - Medium: 4 MB
* - Large: 16 MB
* -# Allocation type
* - device
* - host
* - managed
* Test source
* ------------------------
* - performance/memset/hipMemsetD16Async.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemsetD16Async") {
const auto size = GENERATE(4_KB, 4_MB, 16_MB);
const auto allocation_type = GENERATE(LinearAllocs::hipMalloc, LinearAllocs::hipHostMalloc,
LinearAllocs::hipMallocManaged);
RunBenchmark(allocation_type, size);
}
+80
Zobrazit soubor
@@ -0,0 +1,80 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class MemsetD32Benchmark : public Benchmark<MemsetD32Benchmark> {
public:
MemsetD32Benchmark(LinearAllocs allocation_type, size_t size)
: dst_(allocation_type, size), size_(size) {}
void operator()() {
TIMED_SECTION(kTimerTypeEvent) {
HIP_CHECK(hipMemsetD32(reinterpret_cast<hipDeviceptr_t>(dst_.ptr()), 123'456, size_));
}
}
private:
LinearAllocGuard<void> dst_;
const size_t size_;
};
static void RunBenchmark(LinearAllocs allocation_type, size_t size) {
MemsetD32Benchmark benchmark(allocation_type, size);
benchmark.AddSectionName(std::to_string(size));
benchmark.AddSectionName(GetAllocationSectionName(allocation_type));
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemsetD32`:
* -# Allocation size
* - Small: 4 KB
* - Medium: 4 MB
* - Large: 16 MB
* -# Allocation type
* - device
* - host
* - managed
* Test source
* ------------------------
* - performance/memset/hipMemsetD32.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemsetD32") {
const auto size = GENERATE(4_KB, 4_MB, 16_MB);
const auto allocation_type = GENERATE(LinearAllocs::hipMalloc, LinearAllocs::hipHostMalloc,
LinearAllocs::hipMallocManaged);
RunBenchmark(allocation_type, size);
}
+82
Zobrazit soubor
@@ -0,0 +1,82 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class MemsetD32AsyncBenchmark : public Benchmark<MemsetD32AsyncBenchmark> {
public:
MemsetD32AsyncBenchmark(LinearAllocs allocation_type, size_t size)
: dst_(allocation_type, size), size_(size), stream_(Streams::created) {}
void operator()() {
TIMED_SECTION_STREAM(kTimerTypeEvent, stream_.stream()) {
HIP_CHECK(hipMemsetD32Async(reinterpret_cast<hipDeviceptr_t>(dst_.ptr()), 123'456, size_,
stream_.stream()));
}
}
private:
LinearAllocGuard<void> dst_;
const size_t size_;
StreamGuard stream_;
};
static void RunBenchmark(LinearAllocs allocation_type, size_t size) {
MemsetD32AsyncBenchmark benchmark(allocation_type, size);
benchmark.AddSectionName(std::to_string(size));
benchmark.AddSectionName(GetAllocationSectionName(allocation_type));
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemsetD32Async`:
* -# Allocation size
* - Small: 4 KB
* - Medium: 4 MB
* - Large: 16 MB
* -# Allocation type
* - device
* - host
* - managed
* Test source
* ------------------------
* - performance/memset/hipMemsetD32Async.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemsetD32Async") {
const auto size = GENERATE(4_KB, 4_MB, 16_MB);
const auto allocation_type = GENERATE(LinearAllocs::hipMalloc, LinearAllocs::hipHostMalloc,
LinearAllocs::hipMallocManaged);
RunBenchmark(allocation_type, size);
}
+80
Zobrazit soubor
@@ -0,0 +1,80 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class MemsetD8Benchmark : public Benchmark<MemsetD8Benchmark> {
public:
MemsetD8Benchmark(LinearAllocs allocation_type, size_t size)
: dst_(allocation_type, size), size_(size) {}
void operator()() {
TIMED_SECTION(kTimerTypeEvent) {
HIP_CHECK(hipMemsetD8(reinterpret_cast<hipDeviceptr_t>(dst_.ptr()), 17, size_));
}
}
private:
LinearAllocGuard<void> dst_;
const size_t size_;
};
static void RunBenchmark(LinearAllocs allocation_type, size_t size) {
MemsetD8Benchmark benchmark(allocation_type, size);
benchmark.AddSectionName(std::to_string(size));
benchmark.AddSectionName(GetAllocationSectionName(allocation_type));
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemsetD8`:
* -# Allocation size
* - Small: 4 KB
* - Medium: 4 MB
* - Large: 16 MB
* -# Allocation type
* - device
* - host
* - managed
* Test source
* ------------------------
* - performance/memset/hipMemsetD8.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemsetD8") {
const auto size = GENERATE(4_KB, 4_MB, 16_MB);
const auto allocation_type = GENERATE(LinearAllocs::hipMalloc, LinearAllocs::hipHostMalloc,
LinearAllocs::hipMallocManaged);
RunBenchmark(allocation_type, size);
}
+82
Zobrazit soubor
@@ -0,0 +1,82 @@
/*
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 <performance_common.hh>
#include <resource_guards.hh>
/**
* @addtogroup memset memset
* @{
* @ingroup PerformanceTest
*/
class MemsetD8AsyncBenchmark : public Benchmark<MemsetD8AsyncBenchmark> {
public:
MemsetD8AsyncBenchmark(LinearAllocs allocation_type, size_t size)
: dst_(allocation_type, size), size_(size), stream_(Streams::created) {}
void operator()() {
TIMED_SECTION_STREAM(kTimerTypeEvent, stream_.stream()) {
HIP_CHECK(hipMemsetD8Async(reinterpret_cast<hipDeviceptr_t>(dst_.ptr()), 17, size_,
stream_.stream()));
}
}
private:
LinearAllocGuard<void> dst_;
const size_t size_;
StreamGuard stream_;
};
static void RunBenchmark(LinearAllocs allocation_type, size_t size) {
MemsetD8AsyncBenchmark benchmark(allocation_type, size);
benchmark.AddSectionName(std::to_string(size));
benchmark.AddSectionName(GetAllocationSectionName(allocation_type));
benchmark.Run();
}
/**
* Test Description
* ------------------------
* - Executes `hipMemsetD8Async`:
* -# Allocation size
* - Small: 4 KB
* - Medium: 4 MB
* - Large: 16 MB
* -# Allocation type
* - device
* - host
* - managed
* Test source
* ------------------------
* - performance/memset/hipMemsetD8Async.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Performance_hipMemsetD8Async") {
const auto size = GENERATE(4_KB, 4_MB, 16_MB);
const auto allocation_type = GENERATE(LinearAllocs::hipMalloc, LinearAllocs::hipHostMalloc,
LinearAllocs::hipMallocManaged);
RunBenchmark(allocation_type, size);
}