mirror of
https://github.com/CNugteren/CLBlast.git
synced 2024-07-04 21:36:57 +02:00
Reduce TestMatrix calls for xgemmbatched.
Replace the looped test by a single one with the maximal found offset.
This commit is contained in:
parent
6ac74008b6
commit
bf50c4e53e
|
@ -79,11 +79,9 @@ void XgemmBatched<T>::DoGemmBatched(const Layout layout, const Transpose a_trans
|
||||||
gemm_kernel_id);
|
gemm_kernel_id);
|
||||||
|
|
||||||
// Tests the matrices for validity
|
// Tests the matrices for validity
|
||||||
for (auto batch = size_t{0}; batch < batch_count; ++batch) {
|
TestBatchedMatrixA(a_one, a_two, a_buffer, a_offsets, a_ld, false); // don't test for invalid LD
|
||||||
TestMatrixA(a_one, a_two, a_buffer, a_offsets[batch], a_ld, false); // don't test for invalid LD
|
TestBatchedMatrixB(b_one, b_two, b_buffer, b_offsets, b_ld, false); // don't test for invalid LD
|
||||||
TestMatrixB(b_one, b_two, b_buffer, b_offsets[batch], b_ld, false); // don't test for invalid LD
|
TestBatchedMatrixC(c_one, c_two, c_buffer, c_offsets, c_ld);
|
||||||
TestMatrixC(c_one, c_two, c_buffer, c_offsets[batch], c_ld);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Upload the scalar arguments to the device
|
// Upload the scalar arguments to the device
|
||||||
auto alphas_device = Buffer<T>(context_, BufferAccess::kReadWrite, batch_count);
|
auto alphas_device = Buffer<T>(context_, BufferAccess::kReadWrite, batch_count);
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#ifndef CLBLAST_BUFFER_TEST_H_
|
#ifndef CLBLAST_BUFFER_TEST_H_
|
||||||
#define CLBLAST_BUFFER_TEST_H_
|
#define CLBLAST_BUFFER_TEST_H_
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "utilities/utilities.hpp"
|
#include "utilities/utilities.hpp"
|
||||||
|
|
||||||
namespace clblast {
|
namespace clblast {
|
||||||
|
@ -104,6 +107,32 @@ void TestVectorIndex(const size_t n, const Buffer<T> &buffer, const size_t offse
|
||||||
} catch (const Error<std::runtime_error> &e) { throw BLASError(StatusCode::kInvalidVectorScalar, e.what()); }
|
} catch (const Error<std::runtime_error> &e) { throw BLASError(StatusCode::kInvalidVectorScalar, e.what()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =================================================================================================
|
||||||
|
|
||||||
|
// Tests matrix 'A' for validity in a batched setting
|
||||||
|
template <typename T>
|
||||||
|
void TestBatchedMatrixA(const size_t one, const size_t two, const Buffer<T>& buffer,
|
||||||
|
const std::vector<size_t> &offsets, const size_t ld, const bool test_lead_dim = true) {
|
||||||
|
const auto max_offset = *std::max_element(offsets.begin(), offsets.end());
|
||||||
|
TestMatrixA(one, two, buffer, max_offset, ld, test_lead_dim);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests matrix 'B' for validity in a batched setting
|
||||||
|
template <typename T>
|
||||||
|
void TestBatchedMatrixB(const size_t one, const size_t two, const Buffer<T>& buffer,
|
||||||
|
const std::vector<size_t>& offsets, const size_t ld, const bool test_lead_dim = true) {
|
||||||
|
const auto max_offset = *std::max_element(offsets.begin(), offsets.end());
|
||||||
|
TestMatrixB(one, two, buffer, max_offset, ld, test_lead_dim);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests matrix 'C' for validity in a batched setting
|
||||||
|
template <typename T>
|
||||||
|
void TestBatchedMatrixC(const size_t one, const size_t two, const Buffer<T>& buffer,
|
||||||
|
const std::vector<size_t>& offsets, const size_t ld) {
|
||||||
|
const auto max_offset = *std::max_element(offsets.begin(), offsets.end());
|
||||||
|
TestMatrixC(one, two, buffer, max_offset, ld);
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
} // namespace clblast
|
} // namespace clblast
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue