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

Add saxpy and hadamard product test perf

parent d153d6e3
......@@ -3,15 +3,18 @@ cmake_minimum_required(VERSION 2.8)
add_subdirectory(cmake)
find_package(TBB COMPONENTS tbb REQUIRED)
phoenix_base_project("PhoenixPerformance" "1.4.1"
"Set of performance test"
"https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/PhoenixPerformance")
pull_extra_module("MicroBenchmark" "https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/MicroBenchmark.git")
pull_extra_module("TensorAlloc" "https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/TensorAlloc.git")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${TBB_TBB_INCLUDE_DIRS})
add_subdirectory(src)
......
......@@ -16,6 +16,7 @@ https://cta-lapp.pages.in2p3.fr//PHOENIX_LIBS/PhoenixPerformance/
- c++ compiler >=5.3.1
- cmake > 3
- make
- libtbb, libtbb-dev
# Installation for Users
......
......@@ -32,9 +32,10 @@ function(phoenix_base_project programName programVersion programDescritpion prog
message(STATUS "Build for tests COVERAGE")
set(CTEST_COVERAGE_COMMAND "gcov")
set(SELF_TESTS_MODE yes)
set(CMAKE_CXX_FLAGS "--std=c++20 -Wall -Werror -g -O0 -fprofile-arcs -ftest-coverage" PARENT_SCOPE)
# --std=c++2a is to enable C++20
set(CMAKE_CXX_FLAGS "--std=c++2a -Wall -Werror -g -O0 -fprofile-arcs -ftest-coverage" PARENT_SCOPE)
else()
set(CMAKE_CXX_FLAGS "--std=c++20 -Wall -Werror -g -O2" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "--std=c++2a -Wall -Werror -g -O2" PARENT_SCOPE)
endif()
add_definitions(-D__PROGRAM_VERSION__="${PROGRAM_VERSION}")
......
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
remove_definitions(-O3)
set(EXTRA_DEPENDENCIES tensor_alloc data_stream TBB::tbb)
add_subdirectory(cpp20)
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
add_subdirectory(saxpy)
add_subdirectory(Sequential)
add_subdirectory(Parallel)
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
add_subdirectory(hadamard)
add_subdirectory(saxpy)
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
set(CONFIG_HADAMARD "1000, 2000, 3000, 4000, 5000, 10000, 50000, 100000, 200000, 500000, 1000000, 5000000, 10000000")
set(progSrc hadamard.cpp main.cpp)
phoenix_compileAndRunExample(perf_hadamard_par_O0 "-O0" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_par_O1 "-O1" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_par_O2 "-O2" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_par_O3 "-O3" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_par_Ofast "-Ofast" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_par_vectorize_O3 "-O3 -ftree-vectorize -march=native -mtune=native -mavx2" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_par_vectorize_Ofast "-Ofast -ftree-vectorize -march=native -mtune=native -mavx2" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_plotPerfLogX("hadamard_parBase" perf_hadamard_par_O0 perf_hadamard_par_O1 perf_hadamard_par_O2 perf_hadamard_par_O3 perf_hadamard_par_Ofast)
phoenix_plotPerfLogX("hadamard_parVectorize" perf_hadamard_par_O3 perf_hadamard_par_vectorize_O3 perf_hadamard_par_vectorize_Ofast)
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
//some doc at : https://en.cppreference.com/w/cpp/header/algorithm
#include <algorithm>
//Some doc at : https://en.cppreference.com/w/cpp/header/execution
#include <execution>
#include "hadamard.h"
///Do a classical hadamard product
/** @param[out] tabRes : table of the result
* @param tabX : talbe of x values
* @param tabY : table of y values
* @param nbElement : number of elements in the tables
*/
void hadamard_product(float * tabRes, const float* tabX, const float* tabY, size_t nbElement){
std::transform(std::execution::par_unseq, tabX, tabX + nbElement, tabY, tabRes,
[=](float xi, float yi){ return xi * yi; });
}
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __HADAMARD_PRODUCT_H__
#define __HADAMARD_PRODUCT_H__
#include <iostream>
void hadamard_product(float * tabRes, const float* tabX, const float* tabY, size_t nbElement);
#endif
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include <iostream>
#include "micro_benchmark.h"
#include "PTensor.h"
#include "hadamard.h"
///Get the number of nanoseconds per elements
/** @param nbElement : number of elements of the tables
*/
void evaluateHadamardProduct(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;
}
micro_benchmarkAutoNsPrint("evaluate hadamard", nbElement, hadamard_product, tabRes.getData(), tabX.getData(), tabY.getData(), nbElement);
}
int main(int argc, char** argv){
return micro_benchmarkParseArg(argc, argv, evaluateHadamardProduct);
}
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
set(CONFIG_SAXPY "1000, 2000, 3000, 4000, 5000, 10000, 50000, 100000, 200000, 500000, 1000000, 5000000, 10000000")
set(progSrc saxpy.cpp main.cpp)
phoenix_compileAndRunExample(perf_saxpy_par_O0 "-O0" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_par_O1 "-O1" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_par_O2 "-O2" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_par_O3 "-O3" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_par_Ofast "-Ofast" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_par_vectorize_O3 "-O3 -ftree-vectorize -march=native -mtune=native -mavx2" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_par_vectorize_Ofast "-Ofast -ftree-vectorize -march=native -mtune=native -mavx2" "${CONFIG_SAXPY}" ${progSrc})
phoenix_plotPerfLogX("saxpy_parBase" perf_saxpy_par_O0 perf_saxpy_par_O1 perf_saxpy_par_O2 perf_saxpy_par_O3 perf_saxpy_par_Ofast)
phoenix_plotPerfLogX("saxpy_parVectorize" perf_saxpy_par_O3 perf_saxpy_par_vectorize_O3 perf_saxpy_par_vectorize_Ofast)
/***************************************
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 evaluateHadamardProduct(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, evaluateHadamardProduct);
}
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
//some doc at : https://en.cppreference.com/w/cpp/header/algorithm
#include <algorithm>
//Some doc at : https://en.cppreference.com/w/cpp/header/execution
#include <execution>
#include "saxpy.h"
///Do a classical saxpy
/** @param[out] tabRes : table of the result
* @param tabX : talbe of x values
* @param tabY : table of y values
* @param scal : scalar which multiplies tabX
* @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 + nbElement, tabY, tabRes,
[=](float xi, float yi){ return scal * xi + yi; });
}
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
add_subdirectory(hadamard)
add_subdirectory(saxpy)
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
set(CONFIG_HADAMARD "1000, 2000, 3000, 4000, 5000, 10000")
set(progSrc hadamard.cpp main.cpp)
phoenix_compileAndRunExample(perf_hadamard_seq_O0 "-O0" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_seq_O1 "-O1" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_seq_O2 "-O2" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_seq_O3 "-O3" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_seq_Ofast "-Ofast" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_seq_vectorize_O3 "-O3 -ftree-vectorize -march=native -mtune=native -mavx2" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_compileAndRunExample(perf_hadamard_seq_vectorize_Ofast "-Ofast -ftree-vectorize -march=native -mtune=native -mavx2" "${CONFIG_HADAMARD}" ${progSrc})
phoenix_plotPerf("hadamard_seqBase" perf_hadamard_seq_O0 perf_hadamard_seq_O1 perf_hadamard_seq_O2 perf_hadamard_seq_O3 perf_hadamard_seq_Ofast)
phoenix_plotPerf("hadamard_seqVectorize" perf_hadamard_seq_O3 perf_hadamard_seq_vectorize_O3 perf_hadamard_seq_vectorize_Ofast)
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
//some doc at : https://en.cppreference.com/w/cpp/header/algorithm
#include <algorithm>
//Some doc at : https://en.cppreference.com/w/cpp/header/execution
#include <execution>
#include "hadamard.h"
///Do a classical hadamard product
/** @param[out] tabRes : table of the result
* @param tabX : talbe of x values
* @param tabY : table of y values
* @param nbElement : number of elements in the tables
*/
void hadamard_product(float * tabRes, const float* tabX, const float* tabY, size_t nbElement){
std::transform(std::execution::seq, tabX, tabX + nbElement, tabY, tabRes,
[=](float xi, float yi){ return xi * yi; });
}
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __HADAMARD_PRODUCT_H__
#define __HADAMARD_PRODUCT_H__
#include <iostream>
void hadamard_product(float * tabRes, const float* tabX, const float* tabY, size_t nbElement);
#endif
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include <iostream>
#include "micro_benchmark.h"
#include "PTensor.h"
#include "hadamard.h"
///Get the number of nanoseconds per elements
/** @param nbElement : number of elements of the tables
*/
void evaluateHadamardProduct(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;
}
micro_benchmarkAutoNsPrint("evaluate hadamard", nbElement, hadamard_product, tabRes.getData(), tabX.getData(), tabY.getData(), nbElement);
}
int main(int argc, char** argv){
return micro_benchmarkParseArg(argc, argv, evaluateHadamardProduct);
}
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
set(CONFIG_SAXPY "1000, 2000, 3000, 4000, 5000, 10000")
set(progSrc saxpy.cpp main.cpp)
phoenix_compileAndRunExample(perf_saxpy_seq_O0 "-O0" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_seq_O1 "-O1" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_seq_O2 "-O2" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_seq_O3 "-O3" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_seq_Ofast "-Ofast" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_seq_vectorize_O3 "-O3 -ftree-vectorize -march=native -mtune=native -mavx2" "${CONFIG_SAXPY}" ${progSrc})
phoenix_compileAndRunExample(perf_saxpy_seq_vectorize_Ofast "-Ofast -ftree-vectorize -march=native -mtune=native -mavx2" "${CONFIG_SAXPY}" ${progSrc})
phoenix_plotPerf("saxpy_seqBase" perf_saxpy_seq_O0 perf_saxpy_seq_O1 perf_saxpy_seq_O2 perf_saxpy_seq_O3 perf_saxpy_seq_Ofast)
phoenix_plotPerf("saxpy_seqVectorize" perf_saxpy_seq_O3 perf_saxpy_seq_vectorize_O3 perf_saxpy_seq_vectorize_Ofast)
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