Commit 93eecfff authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add saxpy and hadamard product test perf

parent d153d6e3
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include <iostream>
#include "micro_benchmark.h"
#include "PTensor.h"
#include "saxpy.h"
///Get the number of nanoseconds per elements
/** @param nbElement : number of elements of the tables
*/
void evaluateSaxpy(size_t nbElement){
PTensor<float> tabX(AllocMode::ALIGNED, nbElement);
PTensor<float> tabY(AllocMode::ALIGNED, nbElement);
PTensor<float> tabRes(AllocMode::ALIGNED, nbElement);
for(size_t i(0lu); i < nbElement; ++i){
tabX[i] = i*19lu%11;
tabY[i] = i*27lu%19;
}
float scal(3.0f);
micro_benchmarkAutoNsPrint("evaluate saxpy", nbElement, saxpy, tabRes.getData(), tabX.getData(), tabY.getData(), scal, nbElement);
}
int main(int argc, char** argv){
return micro_benchmarkParseArg(argc, argv, evaluateSaxpy);
}
......@@ -21,7 +21,7 @@
* @param nbElement : number of elements in the tables
*/
void saxpy(float * tabRes, const float* tabX, const float* tabY, float scal, size_t nbElement){
std::transform(std::execution::par_unseq, tabX, tabX + N, tabY, tabRes,
std::transform(std::execution::seq, tabX, tabX + nbElement, tabY, tabRes,
[=](float xi, float yi){ return scal * xi + yi; });
}
......
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __SAXPY_H__
#define __SAXPY_H__
#include <iostream>
void saxpy(float * tabRes, const float* tabX, const float* tabY, float scal, size_t nbElement);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment