35 lines
947 B
C++
35 lines
947 B
C++
#include "math/dense_blas_internal.h"
|
|
|
|
#include <limits>
|
|
#include <stdexcept>
|
|
|
|
namespace fesa::dense_blas_internal {
|
|
|
|
Result<MKL_INT> ToMklSize(const std::size_t size) {
|
|
if (size > static_cast<std::size_t>((std::numeric_limits<MKL_INT>::max)())) {
|
|
return Result<MKL_INT>::Failure(Status::Failure(
|
|
{{Severity::kError,
|
|
"dense-blas-size-overflow",
|
|
{},
|
|
"",
|
|
"",
|
|
"Dense operation size exceeds the MKL integer range."}}));
|
|
}
|
|
return Result<MKL_INT>::Success(static_cast<MKL_INT>(size));
|
|
}
|
|
|
|
void CopyValues(const double* source, const std::size_t size,
|
|
double* destination) {
|
|
if (size == 0U) {
|
|
return;
|
|
}
|
|
|
|
const auto mkl_size = ToMklSize(size);
|
|
if (!mkl_size.HasValue()) {
|
|
throw std::length_error{"Dense copy size exceeds the MKL integer range."};
|
|
}
|
|
cblas_dcopy(mkl_size.Value(), source, 1, destination, 1);
|
|
}
|
|
|
|
} // namespace fesa::dense_blas_internal
|