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

Tru to use the generated proxy library

parent d3b80b5c
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
# Let's compile the hadamard product several times to cover architectures from sse2 to avx512f (in -O3 but could be in -O2)
set(HADAMARD_PRODUCT_BASE_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/hadamard_product.cpp)
add_library(hadamard_product_anyarch SHARED ${HADAMARD_PRODUCT_BASE_SOURCE})
set_property(TARGET hadamard_product_anyarch PROPERTY COMPILE_FLAGS "-O3 -DFLOAT_VECTOR_ALIGNEMENT=16")
add_library(hadamard_product_sse2 SHARED ${HADAMARD_PRODUCT_BASE_SOURCE})
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_BASE_SOURCE})
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_BASE_SOURCE})
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_BASE_SOURCE})
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_BASE_SOURCE})
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_BASE_SOURCE})
set_property(TARGET hadamard_product_avx512f PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx512f -DFLOAT_VECTOR_ALIGNEMENT=32")
set(HADAMARD_PRODUCT_LIBS hadamard_product_anyarch hadamard_product_sse2 hadamard_product_ssse3 hadamard_product_sse4 hadamard_product_avx hadamard_product_avx2 hadamard_product_avx512f)
set(OUTPUT_PROXY_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/hadamard_product.cpp
${CMAKE_CURRENT_BINARY_DIR}/Hadamard_productProxyLoader.cpp)
set_source_files_properties(${OUTPUT_PROXY_SOURCES} PROPERTIES GENERATED yes)
set(OUTPUT_PROXY_FILES ${CMAKE_CURRENT_BINARY_DIR}/hadamard_product.h
${CMAKE_CURRENT_BINARY_DIR}/Hadamard_productProxyLoader.h
${OUTPUT_PROXY_FILES})
add_custom_command(OUTPUT ${OUTPUT_PROXY_FILES}
COMMAND ${CMAKE_BINARY_DIR}/src/phoenix_hpc_proxy -i ${CMAKE_CURRENT_SOURCE_DIR}/hadamard_product.h -l hadamard_product --anyarch=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_anyarch.so --sse2=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_sse2.so --ssse3=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_ssse3.so --sse4.2=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_sse4.so --avx=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_avx.so --avx2=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_avx2.so --avx512f=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_avx512f.so
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS phoenix_hpc_proxy ${HADAMARD_PRODUCT_LIBS}
COMMENT "Create the proxy hadamard product"
)
add_custom_target(create_hadamard_product_proxy ALL DEPENDS ${OUTPUT_PROXY_FILES})
add_library(hadamard_product SHARED ${OUTPUT_PROXY_SOURCES})
add_dependencies(hadamard_product create_hadamard_product_proxy)
add_subdirectory(HadamardProduct)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/HadamardProduct)
add_executable(test_proxy_hadamard_product main.cpp)
target_link_libraries(test_proxy_hadamard_product hadamard_product)
......
project(Phoenix)
cmake_minimum_required(VERSION 2.8)
# Let's compile the hadamard product several times to cover architectures from sse2 to avx512f (in -O3 but could be in -O2)
set(HADAMARD_PRODUCT_BASE_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/hadamard_product.cpp)
add_library(hadamard_product_anyarch SHARED ${HADAMARD_PRODUCT_BASE_SOURCE})
set_property(TARGET hadamard_product_anyarch PROPERTY COMPILE_FLAGS "-O3 -DFLOAT_VECTOR_ALIGNEMENT=16")
add_library(hadamard_product_sse2 SHARED ${HADAMARD_PRODUCT_BASE_SOURCE})
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_BASE_SOURCE})
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_BASE_SOURCE})
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_BASE_SOURCE})
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_BASE_SOURCE})
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_BASE_SOURCE})
set_property(TARGET hadamard_product_avx512f PROPERTY COMPILE_FLAGS "-O3 -ftree-vectorize -march=native -mtune=native -mavx512f -DFLOAT_VECTOR_ALIGNEMENT=32")
set(HADAMARD_PRODUCT_LIBS hadamard_product_anyarch hadamard_product_sse2 hadamard_product_ssse3 hadamard_product_sse4 hadamard_product_avx hadamard_product_avx2 hadamard_product_avx512f)
set(OUTPUT_PROXY_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/hadamard_product.cpp
${CMAKE_CURRENT_BINARY_DIR}/Hadamard_productProxyLoader.cpp)
set_source_files_properties(${OUTPUT_PROXY_SOURCES} PROPERTIES GENERATED yes)
set(OUTPUT_PROXY_FILES ${CMAKE_CURRENT_BINARY_DIR}/hadamard_product.h
${CMAKE_CURRENT_BINARY_DIR}/Hadamard_productProxyLoader.h
${OUTPUT_PROXY_FILES})
add_custom_command(OUTPUT ${OUTPUT_PROXY_FILES}
COMMAND ${CMAKE_BINARY_DIR}/src/phoenix_hpc_proxy -i ${CMAKE_CURRENT_SOURCE_DIR}/hadamard_product.h -l hadamard_product --anyarch=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_anyarch.so --sse2=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_sse2.so --ssse3=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_ssse3.so --sse4.2=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_sse4.so --avx=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_avx.so --avx2=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_avx2.so --avx512f=${CMAKE_CURRENT_BINARY_DIR}/libhadamard_product_avx512f.so
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS phoenix_hpc_proxy ${HADAMARD_PRODUCT_LIBS}
COMMENT "Create the proxy hadamard product"
)
add_custom_target(create_hadamard_product_proxy ALL DEPENDS ${OUTPUT_PROXY_FILES})
add_library(hadamard_product SHARED ${OUTPUT_PROXY_SOURCES})
add_dependencies(hadamard_product create_hadamard_product_proxy)
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include <iostream>
///Test the proxy library
void testProxyLib(){
}
int main(int argc, char** argv){
testProxyLib();
return 0;
}
//Comment
void print_arch(const char* str);
......@@ -138,11 +138,13 @@ std::string cpp_backendHeader(PSource & source){
std::string getMangleFunctionName(const std::string & libraryName, const std::string & functionName){
if(libraryName == ""){return functionName;}
std::string outputTmpFile(".mangledFunctionName.txt");
std::string command("objdump --syms "+libraryName+" | grep "+functionName+" | sed -e \"s/ /\\n/g\" | grep "+functionName+" | sed -e s/\\.cold//g | head -n 1 > "+outputTmpFile);
std::string command("objdump --syms "+libraryName+" | grep \".text\" | sed -e \"s/ /\\n/g\" | grep "+functionName+" | head -n 1 > "+outputTmpFile);
if(system(command.c_str()) != 0){
return "";
return functionName;
}
std::string mangleFunction(eraseCharsInStr(getFileContent(outputTmpFile), "\n\t "));
std::string fullFileContent(getFileContent(outputTmpFile));
std::cerr << "getMangleFunctionName : full file content mangle function '"<<functionName<<"' : " << fullFileContent << std::endl;
std::string mangleFunction(eraseCharsInStr(fullFileContent, "\n\t "));
if(remove(outputTmpFile.c_str()) != 0){
std::cerr << "DPS::LibraryHandle::mangleFunctionName : cannot remove file '"<<outputTmpFile<<"'" << std::endl;
}
......
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