Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXSWHTEC-224 - Test cases ID clean up and documentation for Occupancy #93

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cea96af
SWDEV-355313 - Move catch tests and samples
gargrahul Oct 26, 2022
909e7e4
SWDEV-355313 - Add README
gargrahul Nov 7, 2022
094b9af
SWDEV-355313 - Update amd-staging branch
gargrahul Nov 28, 2022
070bb7c
EXSWHTEC-174 - Add Doxygen configuration and common header with group…
milos-mozetic Dec 1, 2022
9daa6d0
SWDEV-355313 - Update README
gargrahul Dec 2, 2022
2a205ed
EXSWHTEC-200 - Add support for TEMPLATE_TEST_CASE preprocessing
milos-mozetic Dec 5, 2022
c49043e
SWDEV-355313 - Update latest code
gargrahul Dec 6, 2022
e0a7d7b
EXSWHTEC-106 - Reimplement tests for hipOccupancyMaxActiveBlocksPerMu…
nives-vukovic Dec 9, 2022
e095d78
EXSWHTEC-106 - Change section disable macros
nives-vukovic Dec 9, 2022
105cf2a
EXSWHTEC-105 - Implement tests for hipModuleOccupancyMaxActiveBlocksP…
nives-vukovic Dec 9, 2022
2db594f
Merge branch 'develop' of github.com:mirza-halilcevic/hip-tests into …
milos-mozetic Dec 13, 2022
1977515
EXSWHTEC-200 - Resolve conflicts in missed conflicted files
milos-mozetic Dec 13, 2022
14a4667
Merge remote-tracking branch 'origin/develop' into hipOccupancy_tests
nives-vukovic Dec 14, 2022
5260f80
Merge remote-tracking branch 'origin/develop' into hipModuleOccupancy…
nives-vukovic Dec 14, 2022
259be27
EXSWHTEC-200 - Add newline at the end of the file
milos-mozetic Dec 14, 2022
e0daf30
EXSWHTEC-200 - Extend the PREDEFINED list to define all macro names t…
milos-mozetic Dec 14, 2022
ed554f2
EXSWHTEC-106 - Disable AMD specific test due to defect
nives-vukovic Dec 20, 2022
a048cff
Merge branch 'hipOccupancy_tests' of github.com:mirza-halilcevic/hip-…
milos-mozetic Dec 20, 2022
9bf92de
Merge branch 'hipModuleOccupancy_tests' of github.com:mirza-halilcevi…
milos-mozetic Dec 20, 2022
e13aa21
EXSWHTEC-224 - Test cases ID clean up and documentation for Occupancy
milos-mozetic Dec 20, 2022
2dc90fd
EXSWHTEC-105 - Disable negative test using json file
nives-vukovic Mar 9, 2023
4c8b7f6
Merge branch 'develop' into doxygen_occupancy_documentation
milos-mozetic Jun 22, 2023
3be5ef1
Merge remote-tracking branch 'origin/develop' into hipModuleOccupancy…
nives-vukovic Jun 26, 2023
a68bfcd
Merge branch 'develop' of github.com:mirza-halilcevic/hip-tests into …
milos-mozetic Jul 10, 2023
d7d63fb
Merge branch 'develop' into doxygen_occupancy_documentation
rakesroy Jul 25, 2023
1368d91
Merge remote-tracking branch 'origin/develop' into hipModuleOccupancy…
nives-vukovic Nov 16, 2023
47b7285
Merge remote-tracking branch 'origin/develop' into doxygen_occupancy_…
nives-vukovic Nov 20, 2023
a340275
Merge branch 'hipModuleOccupancy_tests' into doxygen_occupancy_docume…
nives-vukovic Nov 20, 2023
d5708c4
Merge remote-tracking branch 'origin/develop' into doxygen_occupancy_…
nives-vukovic Feb 5, 2024
9085493
EXSWHTEC-224 - Fix minor cleanup inconsistencies
nives-vukovic Feb 20, 2024
60eb35e
Merge branch 'develop' into doxygen_occupancy_documentation
mirza-halilcevic Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,540 changes: 2,540 additions & 0 deletions catch/DoxyfileTests

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions catch/include/hip_test_defgroups.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright (c) 2021 - 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.
*/

// Test groups are named based on the group names from hip_api_runtime.h, with adding "Test" suffix

/**
* @defgroup CallbackTest Callback Activity APIs
* @{
* This section describes tests for the callback/Activity of HIP runtime API.
* @}
*/

/**
* @defgroup GraphTest Graph Management
* @{
* This section describes the graph management types & functions of HIP runtime API.
* @}
*/

/**
* @defgroup OccupancyTest Occupancy
* @{
* This section describes tests for the occupancy functions of HIP runtime API.
* @}
*/
14 changes: 14 additions & 0 deletions catch/unit/occupancy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# Common Tests - Test independent of all platforms
set(TEST_SRC
hipOccupancyMaxActiveBlocksPerMultiprocessor.cc
hipOccupancyMaxActiveBlocksPerMultiprocessor_old.cc
hipOccupancyMaxPotentialBlockSize.cc
hipOccupancyMaxPotentialBlockSize_old.cc
hipModuleOccupancyMaxPotentialBlockSize.cc
hipModuleOccupancyMaxPotentialBlockSizeWithFlags.cc
hipModuleOccupancyMaxActiveBlocksPerMultiprocessor.cc
hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags.cc
)

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/simple_kernel.code
COMMAND ${CMAKE_CXX_COMPILER} --genco --std=c++17 ${CMAKE_CURRENT_SOURCE_DIR}/simple_kernel.cc -o simple_kernel.code
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/simple_kernel.cc)

add_custom_target(simple_kernel ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simple_kernel.code)

hip_add_exe_to_target(NAME OccupancyTest
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests)

add_dependencies(OccupancyTest simple_kernel)
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
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 "occupancy_common.hh"

/**
* @addtogroup hipModuleOccupancyMaxActiveBlocksPerMultiprocessor hipModuleOccupancyMaxActiveBlocksPerMultiprocessor
* @{
* @ingroup OccupancyTest
* `hipModuleOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks, hipFunction_t f,
* int blockSize, size_t dynSharedMemPerBlk)` -
* Returns occupancy for a device function.
*/

/**
* Test Description
* ------------------------
* - Validates handling of invalid arguments:
* -# When output pointer to the grid size is `nullptr`
* - Expected output: return `hipErrorInvalidValue`
* -# When block size is 0
* - Expected output: return `hipErrorInvalidValue`
* Test source
* ------------------------
* - unit/occupancy/hipModuleOccupancyMaxActiveBlocksPerMultiprocessor.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipModuleOccupancyMaxActiveBlocksPerMultiprocessor_Negative_Parameters") {
hipModule_t module;
hipFunction_t function;
int blockSize = 0;
int gridSize = 0;

HIP_CHECK(hipFree(nullptr));

HIP_CHECK(hipModuleLoad(&module, "simple_kernel.code"));
HIPCHECK(hipModuleGetFunction(&function, module, "SimpleKernel"));

// Get potential blocksize
HIP_CHECK(hipModuleOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, function, 0, 0));

// Common negative tests
MaxActiveBlocksPerMultiprocessorNegative(
[&function](int* numBlocks, int blockSize, size_t dynSharedMemPerBlk) {
return hipModuleOccupancyMaxActiveBlocksPerMultiprocessor(numBlocks, function, blockSize,
dynSharedMemPerBlk);
},
blockSize);

HIP_CHECK(hipModuleUnload(module));
}

/**
* Test Description
* ------------------------
* - Check if grid size and block size are within valid range using basic kernel functions:
* -# When `dynSharedMemPerBlk = 0`
* - Expected output: return `hipSuccess`
* -# When `dynSharedMemPerBlk = sharedMemPerBlock`
* - Expected output: return `hipSuccess`
* Test source
* ------------------------
* - unit/occupancy/hipModuleOccupancyMaxActiveBlocksPerMultiprocessor.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipModuleOccupancyMaxActiveBlocksPerMultiprocessor_Positive_RangeValidation") {
hipDeviceProp_t devProp;
hipModule_t module;
hipFunction_t function;
int blockSize = 0;
int gridSize = 0;

HIP_CHECK(hipFree(nullptr));

HIP_CHECK(hipModuleLoad(&module, "simple_kernel.code"));
HIPCHECK(hipModuleGetFunction(&function, module, "SimpleKernel"));

HIP_CHECK(hipGetDeviceProperties(&devProp, 0));

SECTION("dynSharedMemPerBlk = 0") {
// Get potential blocksize
HIP_CHECK(hipModuleOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, function, 0, 0));

MaxActiveBlocksPerMultiprocessor(
[blockSize, &function](int* numBlocks) {
return hipModuleOccupancyMaxActiveBlocksPerMultiprocessor(numBlocks, function, blockSize,
0);
},
blockSize, devProp.maxThreadsPerMultiProcessor);
}
SECTION("dynSharedMemPerBlk = sharedMemPerBlock") {
// Get potential blocksize
HIP_CHECK(hipModuleOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, function,
devProp.sharedMemPerBlock, 0));

MaxActiveBlocksPerMultiprocessor(
[blockSize, devProp, &function](int* numBlocks) {
return hipModuleOccupancyMaxActiveBlocksPerMultiprocessor(numBlocks, function, blockSize,
devProp.sharedMemPerBlock);
},
blockSize, devProp.maxThreadsPerMultiProcessor);
}

HIP_CHECK(hipModuleUnload(module));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
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 "occupancy_common.hh"

/**
* @addtogroup hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
* @{
* @ingroup OccupancyTest
* `hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int* numBlocks, hipFunction_t f,
* int blockSize, size_t dynSharedMemPerBlk, unsigned int flags)` -
* Returns occupancy for a device function.
*/

/**
* Test Description
* ------------------------
* - Validates handling of invalid arguments:
* -# When output pointer to the grid size is `nullptr`
* - Expected output: return `hipErrorInvalidValue`
* -# When block size is 0
* - Expected output: return `hipErrorInvalidValue`
* -# When flag is invalid, because only default flag is supported
* - Platform specific (NVIDIA)
* - Expected output: return `hipErrorInvalidValue`
* Test source
* ------------------------
* - unit/occupancy/hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_Negative_Parameters") {
hipModule_t module;
hipFunction_t function;
int numBlocks = 0;
int blockSize = 0;
int gridSize = 0;

HIP_CHECK(hipFree(nullptr));

HIP_CHECK(hipModuleLoad(&module, "simple_kernel.code"));
HIPCHECK(hipModuleGetFunction(&function, module, "SimpleKernel"));

// Get potential blocksize
HIP_CHECK(hipModuleOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, function, 0, 0));

// Common negative tests
MaxActiveBlocksPerMultiprocessorNegative(
[&function](int* numBlocks, int blockSize, size_t dynSharedMemPerBlk) {
return hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
numBlocks, function, blockSize, dynSharedMemPerBlk, hipOccupancyDefault);
},
blockSize);

#if HT_NVIDIA // EXSWHTEC-219
SECTION("Flag is invalid") {
// Only default flag is supported
HIP_CHECK_ERROR(hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
&numBlocks, function, blockSize, 0, 2),
hipErrorInvalidValue);
}
#endif

HIP_CHECK(hipModuleUnload(module));
}

/**
* Test Description
* ------------------------
* - Check if grid size and block size are within valid range using basic kernel functions:
* -# When `dynSharedMemPerBlk = 0`
* - Expected output: return `hipSuccess`
* -# When `dynSharedMemPerBlk = sharedMemPerBlock`
* - Expected output: return `hipSuccess`
* Test source
* ------------------------
* - unit/occupancy/hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE(
"Unit_hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_Positive_RangeValidation") {
hipDeviceProp_t devProp;
hipModule_t module;
hipFunction_t function;
int blockSize = 0;
int gridSize = 0;

HIP_CHECK(hipFree(nullptr));

HIP_CHECK(hipModuleLoad(&module, "simple_kernel.code"));
HIPCHECK(hipModuleGetFunction(&function, module, "SimpleKernel"));

HIP_CHECK(hipGetDeviceProperties(&devProp, 0));

SECTION("dynSharedMemPerBlk = 0") {
// Get potential blocksize
HIP_CHECK(hipModuleOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, function, 0, 0));

MaxActiveBlocksPerMultiprocessor(
[blockSize, &function](int* numBlocks) {
return hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
numBlocks, function, blockSize, 0, hipOccupancyDefault);
},
blockSize, devProp.maxThreadsPerMultiProcessor);
}
SECTION("dynSharedMemPerBlk = sharedMemPerBlock") {
// Get potential blocksize
HIP_CHECK(hipModuleOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, function,
devProp.sharedMemPerBlock, 0));

MaxActiveBlocksPerMultiprocessor(
[blockSize, devProp, &function](int* numBlocks) {
return hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
numBlocks, function, blockSize, devProp.sharedMemPerBlock, hipOccupancyDefault);
},
blockSize, devProp.maxThreadsPerMultiProcessor);
}

HIP_CHECK(hipModuleUnload(module));
}
Loading