2021-06-02 15:36:44 -04:00
|
|
|
#include "FunctionTable.hpp"
|
|
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
|
* Random number generation *
|
|
|
|
|
********************************************************/
|
2021-09-02 08:19:54 -04:00
|
|
|
/*template<> char genRand<char>()
|
2021-06-02 15:36:44 -04:00
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<char> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> int8_t genRand<int8_t>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<int8_t> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> uint8_t genRand<uint8_t>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<uint8_t> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> int16_t genRand<int16_t>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<int16_t> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> uint16_t genRand<uint16_t>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<uint16_t> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> int32_t genRand<int32_t>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<int32_t> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> uint32_t genRand<uint32_t>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<uint32_t> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> int64_t genRand<int64_t>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<int64_t> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> uint64_t genRand<uint64_t>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_int_distribution<uint64_t> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> float genRand<float>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_real_distribution<float> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> double genRand<double>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_real_distribution<double> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
|
|
|
|
template<> long double genRand<long double>()
|
|
|
|
|
{
|
|
|
|
|
static std::random_device rd;
|
|
|
|
|
static std::mt19937 gen( rd() );
|
|
|
|
|
static std::uniform_real_distribution<double> dis;
|
|
|
|
|
return dis( gen );
|
|
|
|
|
}
|
2021-09-02 08:19:54 -04:00
|
|
|
*/
|
2021-06-02 15:36:44 -04:00
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
|
* axpy *
|
|
|
|
|
********************************************************/
|
2021-11-08 22:58:37 +01:00
|
|
|
template <>
|
|
|
|
|
void call_axpy<float>(size_t N, const float alpha, const float *x, float *y) {
|
2021-06-02 15:36:44 -04:00
|
|
|
ERROR("Not finished");
|
|
|
|
|
}
|
2021-11-08 22:58:37 +01:00
|
|
|
template <>
|
|
|
|
|
void call_axpy<double>(size_t N, const double alpha, const double *x,
|
|
|
|
|
double *y) {
|
2021-06-02 15:36:44 -04:00
|
|
|
ERROR("Not finished");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
|
* Multiply two arrays *
|
|
|
|
|
********************************************************/
|
2021-11-08 22:58:37 +01:00
|
|
|
template <>
|
|
|
|
|
void call_gemv<double>(size_t M, size_t N, double alpha, double beta,
|
|
|
|
|
const double *A, const double *x, double *y) {
|
2021-06-02 15:36:44 -04:00
|
|
|
ERROR("Not finished");
|
|
|
|
|
}
|
2021-11-08 22:58:37 +01:00
|
|
|
template <>
|
|
|
|
|
void call_gemv<float>(size_t M, size_t N, float alpha, float beta,
|
|
|
|
|
const float *A, const float *x, float *y) {
|
2021-06-02 15:36:44 -04:00
|
|
|
ERROR("Not finished");
|
|
|
|
|
}
|
2021-11-08 22:58:37 +01:00
|
|
|
template <>
|
|
|
|
|
void call_gemm<double>(size_t M, size_t N, size_t K, double alpha, double beta,
|
|
|
|
|
const double *A, const double *B, double *C) {
|
2021-06-02 15:36:44 -04:00
|
|
|
ERROR("Not finished");
|
|
|
|
|
}
|
2021-11-08 22:58:37 +01:00
|
|
|
template <>
|
|
|
|
|
void call_gemm<float>(size_t M, size_t N, size_t K, float alpha, float beta,
|
|
|
|
|
const float *A, const float *B, float *C) {
|
2021-06-02 15:36:44 -04:00
|
|
|
ERROR("Not finished");
|
|
|
|
|
}
|