Skip to content

Commit

Permalink
Address test commit feedback
Browse files Browse the repository at this point in the history
* Fix half tests by changing the initialization values
* Reduced the no. of tests executed
  • Loading branch information
muhammad-tanvir-1211 committed Feb 22, 2024
1 parent 23dff65 commit fe55302
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 66 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ Some of the supported options are:
| `CMAKE_INSTALL_PREFIX` | path | Specify the install location, used when invoking `ninja install` |
| `BUILD_SHARED_LIBS` | `ON`/`OFF` | Build as shared library (`ON` by default) |
| `ENABLE_EXPRESSION_TESTS` | `ON`/`OFF` | Build additional tests that use the header-only framework (e.g to test expression trees); `OFF` by default |
| `ENABLE_JOINTMATRIX_TESTS` | `ON`/`OFF` | Build additional tests that use joint_matrix extension; `OFF` by default |
| `BLAS_VERIFY_BENCHMARK` | `ON`/`OFF` | Verify the results of the benchmarks instead of only measuring the performance. See the documentation of the benchmarks for more details. `ON` by default |
| `BLAS_MEMPOOL_BENCHMARK` | `ON`/`OFF` | Determines whether to enable the scratchpad memory pool for benchmark execution. `OFF` by default |
| `BLAS_ENABLE_CONST_INPUT` | `ON`/`OFF` | Determines whether to enable kernel instantiation with const input buffer (`ON` by default) |
Expand Down
20 changes: 12 additions & 8 deletions test/blas_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,27 +225,31 @@ static inline void fill_trsm_matrix(std::vector<scalar_t> &A, size_t k,

/**
* @brief Set to zero the last n bits of a float.
*
* @tparam T value type.
* @param val input/output float value.
* @param nbits number of last bit set to zero. It is set by default to 13 since
* this is the difference of the number of bits of the mantissa between floats
* (23) and FP16 / NVIDIA TF32 (10). For bfloat16, this value needs to be set to
* 16 to get correct result.
*/
static inline void set_to_zero_last_nbits(float &val, int32_t nbits = 13) {
int32_t *int_pntr = reinterpret_cast<int32_t *>(&val);
*int_pntr = (*int_pntr >> nbits) << nbits;
template <typename T>
void set_to_zero_last_nbits(T &val, int32_t nbits = 13) {
static_assert(sizeof(T) <= 64);
using integer_t =
std::conditional_t<sizeof(T) == 64, int64_t,
int32_t>;
integer_t *int_pntr = reinterpret_cast<integer_t *>(&val);
}

/**
* @brief Set to zero the last n bits of floats contained in a vector.
*
* @tparam T value type.
* @param val input/output float vector.
* @param nbits number of last bit set to zero.
*/
static inline void set_to_zero_last_nbits(std::vector<float> &vec,
int32_t nbits = 13) {
for (float &val : vec) set_to_zero_last_nbits(val, nbits);
template <typename T>
void set_to_zero_last_nbits(std::vector<T> &vec, int32_t nbits = 13) {
for (T &val : vec) set_to_zero_last_nbits(val, nbits);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/unittest/blas3/blas3_trsm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ void run_test(const combination_t<scalar_t> combi) {
sb_handle.wait(event);

bool isAlmostEqual = utils::compare_vectors(
cpu_B, B, std::cerr, "",
cpu_B, B, std::cerr, "\n",
(en_joint_matrix != NULL) && (std::is_same<scalar_t, float>::value) &&
(*en_joint_matrix == '1')
? 2
? 3
: 1);

ASSERT_TRUE(isAlmostEqual);
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/joint_matrix/bfloat16_float_16_16_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const auto SmallMatricesBfloat16Floatm16n16k16 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(11, 16, 32, 63), // m
::testing::Values(11, 16, 32, 63), // n
Expand All @@ -58,10 +58,10 @@ const auto MediumMatricesBfloat16Floatm16n16k16 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(65, 127, 234, 511, 768), // m
::testing::Values(65, 127, 234, 511, 768), // n
::testing::Values(65, 127, 234, 511), // m
::testing::Values(65, 127, 234, 511), // n
::testing::Values(65, 127), // k
::testing::Values('n', 't'), // transa
::testing::Values('n', 't'), // transb
Expand All @@ -82,7 +82,7 @@ const auto LargeMatricesBfloat16Floatm16n16k16 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(1024, 1535, 2024), // m
::testing::Values(1024, 1535, 2024), // n
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/joint_matrix/bfloat16_float_32_8_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const auto SmallMatricesBfloat16Floatm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(11, 16, 32, 63), // m
::testing::Values(11, 16, 32, 63), // n
Expand All @@ -58,10 +58,10 @@ const auto MediumMatricesBfloat16Floatm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(65, 127, 234, 511, 768), // m
::testing::Values(65, 127, 234, 511, 768), // n
::testing::Values(65, 127, 234, 511), // m
::testing::Values(65, 127, 234, 511), // n
::testing::Values(65, 127), // k
::testing::Values('n', 't'), // transa
::testing::Values('n', 't'), // transb
Expand All @@ -82,7 +82,7 @@ const auto LargeMatricesBfloat16Floatm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(1024, 1535, 2024), // m
::testing::Values(1024, 1535, 2024), // n
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/joint_matrix/bfloat16_float_8_32_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const auto SmallMatricesBfloat16Floatm8n32k16 = ::testing::Combine(
::testing::Values(32), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(11, 16, 32, 63), // m
::testing::Values(11, 16, 32, 63), // n
Expand All @@ -58,10 +58,10 @@ const auto MediumMatricesBfloat16Floatm8n32k16 = ::testing::Combine(
::testing::Values(32), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(65, 127, 234, 511, 768), // m
::testing::Values(65, 127, 234, 511, 768), // n
::testing::Values(65, 127, 234, 511), // m
::testing::Values(65, 127, 234, 511), // n
::testing::Values(65, 127), // k
::testing::Values('n', 't'), // transa
::testing::Values('n', 't'), // transb
Expand All @@ -82,7 +82,7 @@ const auto LargeMatricesBfloat16Floatm8n32k16 = ::testing::Combine(
::testing::Values(32), // jm_n
::testing::Values(16), // jm_k
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(1024, 1535, 2024), // m
::testing::Values(1024, 1535, 2024), // n
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/joint_matrix/half_float_16_16_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const auto SmallMatricesHalfFloat161616 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(11, 16, 32, 63), // m
::testing::Values(11, 16, 32, 63), // n
Expand All @@ -58,10 +58,10 @@ const auto MediumMatricesHalfFloat161616 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(65, 127, 234, 511, 768), // m
::testing::Values(65, 127, 234, 511, 768), // n
::testing::Values(65, 127, 234, 511), // m
::testing::Values(65, 127, 234, 511), // n
::testing::Values(65, 127), // k
::testing::Values('n', 't'), // transa
::testing::Values('n', 't'), // transb
Expand All @@ -82,7 +82,7 @@ const auto LargeMatricesHalfFloat161616 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(1024, 1535, 2024), // m
::testing::Values(1024, 1535, 2024), // n
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/joint_matrix/half_float_32_8_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const auto SmallMatricesHalfFloatm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(11, 16, 32, 63), // m
::testing::Values(11, 16, 32, 63), // n
Expand All @@ -58,10 +58,10 @@ const auto MediumMatricesHalfFloatm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(65, 127, 234, 511, 768), // m
::testing::Values(65, 127, 234, 511, 768), // n
::testing::Values(65, 127, 234, 511), // m
::testing::Values(65, 127, 234, 511), // n
::testing::Values(65, 127), // k
::testing::Values('n', 't'), // transa
::testing::Values('n', 't'), // transb
Expand All @@ -82,7 +82,7 @@ const auto LargeMatricesHalfFloatm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(1024, 1535, 2024), // m
::testing::Values(1024, 1535, 2024), // n
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/joint_matrix/half_float_8_32_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const auto SmallMatricesHalfFloatm8n32k16 = ::testing::Combine(
::testing::Values(32), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(11, 16, 32, 63), // m
::testing::Values(11, 16, 32, 63), // n
Expand All @@ -58,10 +58,10 @@ const auto MediumMatricesHalfFloatm8n32k16 = ::testing::Combine(
::testing::Values(32), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(65, 127, 234, 511, 768), // m
::testing::Values(65, 127, 234, 511, 768), // n
::testing::Values(65, 127, 234, 511), // m
::testing::Values(65, 127, 234, 511), // n
::testing::Values(65, 127), // k
::testing::Values('n', 't'), // transa
::testing::Values('n', 't'), // transb
Expand All @@ -82,7 +82,7 @@ const auto LargeMatricesHalfFloatm8n32k16 = ::testing::Combine(
::testing::Values(32), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(1024, 1535, 2024), // m
::testing::Values(1024, 1535, 2024), // n
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/joint_matrix/half_half_16_16_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const auto SmallMatricesHalfHalfm16n16k16 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(11, 16, 32, 63), // m
::testing::Values(11, 16, 32, 63), // n
Expand All @@ -58,10 +58,10 @@ const auto MediumMatricesHalfHalfm16n16k16 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(65, 127, 234, 511, 768), // m
::testing::Values(65, 127, 234, 511, 768), // n
::testing::Values(65, 127, 234, 511), // m
::testing::Values(65, 127, 234, 511), // n
::testing::Values(65, 127), // k
::testing::Values('n', 't'), // transa
::testing::Values('n', 't'), // transb
Expand All @@ -82,7 +82,7 @@ const auto LargeMatricesHalfHalfm16n16k16 = ::testing::Combine(
::testing::Values(16), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(1024, 1535, 2024), // m
::testing::Values(1024, 1535, 2024), // n
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/joint_matrix/half_half_32_8_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const auto SmallMatricesHalfHalfm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(11, 16, 32, 63), // m
::testing::Values(11, 16, 32, 63), // n
Expand All @@ -58,10 +58,10 @@ const auto MediumMatricesHalfHalfm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(65, 127, 234, 511, 768), // m
::testing::Values(65, 127, 234, 511, 768), // n
::testing::Values(65, 127, 234, 511), // m
::testing::Values(65, 127, 234, 511), // n
::testing::Values(65, 127), // k
::testing::Values('n', 't'), // transa
::testing::Values('n', 't'), // transb
Expand All @@ -82,7 +82,7 @@ const auto LargeMatricesHalfHalfm32n8k16 = ::testing::Combine(
::testing::Values(8), // jm_n
::testing::Values(16), // jm_n
::testing::Values("usm", "buf"), // allocation type
::testing::Values(0, 33), // offset
::testing::Values(33), // offset
::testing::Values(1), // batch
::testing::Values(1024, 1535, 2024), // m
::testing::Values(1024, 1535, 2024), // n
Expand Down
Loading

0 comments on commit fe55302

Please sign in to comment.