Commit f8830fd9 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Create a basic library for hadamard product

parent 230529c1
......@@ -2,4 +2,5 @@ project(Phoenix)
cmake_minimum_required(VERSION 2.8)
add_subdirectory(TEST_BASE_HEADER)
add_subdirectory(TEST_PROXY_LIB)
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
add_library(hadamard_product_sse2 SHARED hadamard_product.cpp)
set_property(TARGET hadamard_product_sse2 PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -msse2 -DFLOAT_VECTOR_ALIGNEMENT=16")
add_library(hadamard_product_ssse3 SHARED hadamard_product.cpp)
set_property(TARGET hadamard_product_ssse3 PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mssse3 -DFLOAT_VECTOR_ALIGNEMENT=16")
add_library(hadamard_product_sse4 SHARED hadamard_product.cpp)
set_property(TARGET hadamard_product_sse4 PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -msse4 -DFLOAT_VECTOR_ALIGNEMENT=16")
add_library(hadamard_product_avx SHARED hadamard_product.cpp)
set_property(TARGET hadamard_product_avx PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx -DFLOAT_VECTOR_ALIGNEMENT=32")
add_library(hadamard_product_avx2 SHARED hadamard_product.cpp)
set_property(TARGET hadamard_product_avx2 PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx2 -DFLOAT_VECTOR_ALIGNEMENT=32")
add_library(hadamard_product_avx512f SHARED hadamard_product.cpp)
set_property(TARGET hadamard_product_avx512f PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx512f -DFLOAT_VECTOR_ALIGNEMENT=32")
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include "hadamard_product.h"
///Do the Hadamard product
/** @param[out] ptabResult : table of results of tabX*tabY
* @param ptabX : input table
* @param ptabY : input table
* @param nbElement : number of elements in the tables
*/
void hadamard_product(float* __restrict__ ptabResult, const float* __restrict__ ptabX, const float* __restrict__ ptabY, long unsigned int nbElement){
const float* tabX = (const float*)__builtin_assume_aligned(ptabX, FLOAT_VECTOR_ALIGNEMENT);
const float* tabY = (const float*)__builtin_assume_aligned(ptabY, FLOAT_VECTOR_ALIGNEMENT);
float* tabResult = (float*)__builtin_assume_aligned(ptabResult, FLOAT_VECTOR_ALIGNEMENT);
for(long unsigned int i(0lu); i < nbElement; ++i){
tabResult[i] = tabX[i]*tabY[i];
}
}
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __HADAMARD_PRODUCT_H__
#define __HADAMARD_PRODUCT_H__
void hadamard_product(float* __restrict__ ptabResult, const float* __restrict__ ptabX, const float* __restrict__ ptabY, long unsigned int nbElement);
#endif
//Comment
void print_arch(const char* str);
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