Commit 01d49a1d authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Need to update the type/variable parsing

parent fc809cb2
#ifndef __PRINT_ARCH_H__
#define __PRINT_ARCH_H__
void print_arch(const char* str);
#endif
......@@ -3,25 +3,59 @@ 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)
add_library(hadamard_product_sse2 SHARED hadamard_product.cpp)
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.cpp)
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.cpp)
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.cpp)
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.cpp)
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.cpp)
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)
......@@ -61,6 +61,7 @@ bool HeaderParser::parseFile(){
PFunction function;
if(parseDocString()){}
else if(p_parser->isMatch("//")){p_parser->getUntilKeyWithoutPatern("\n");} //Skip comment
else if(parseMacro()){}
else if(parseFunction(function)){
p_currentSource.getVecFunction().push_back(function);
}else{
......@@ -110,6 +111,18 @@ void HeaderParser::playOtherCode(){
}
}
///Parse a macro
/** @return true on success, false otherwise
*/
bool HeaderParser::parseMacro(){
if(!p_parser->isMatch("#")){return false;}
std::string macro("#" + p_parser->getUntilKeyWithoutPatern("\n") + "\n");
PFunction func;
func.setOtherCode(macro);
p_currentSource.getVecFunction().push_back(func);
return true;
}
///Parse a doc string
/** @return true on success, false otherwise
*/
......@@ -197,18 +210,24 @@ bool HeaderParser::parseArgument(PArgument & arg){
std::string type("");
parseType(type);
std::string varName(""), ptrRef("");
std::string varName(""), ptrRef(""), tmpPtrRef("");
tmpPtrRef = p_parser->getNextToken();
// ptrRef = p_parser->getNextToken();
ptrRef = p_parser->getNextToken();
if(findCharsInString(ptrRef, "&*")){
while(findCharsInString(ptrRef, "&*")){
ptrRef += p_parser->getNextToken();
if(findCharsInString(tmpPtrRef, "&*")/* || tmpPtrRef == "__restrict__"*/){
while(findCharsInString(tmpPtrRef, "&*")/* || tmpPtrRef == "__restrict__"*/){
tmpPtrRef = p_parser->getNextToken();
// if(tmpPtrRef == "__restrict__"){ptrRef += " ";}
ptrRef += tmpPtrRef;
}
varName = p_parser->getNextToken();
}else{
ptrRef = tmpPtrRef;
varName = ptrRef;
ptrRef = "";
}
std::cerr << "HeaderParser::parseArgument : varName = '"<<varName<<"', ptrRef = '"<<ptrRef<<"'" << std::endl;
std::string defaultValue("");
if(p_parser->isMatch("=")){ //Some default value
defaultValue = p_parser->getNextToken();
......@@ -234,7 +253,7 @@ bool HeaderParser::parseArgument(PArgument & arg){
void HeaderParser::parseType(std::string & type){
type = "";
std::string token(p_parser->getNextToken());
while(token == "const" || token == "unsigned"){
while(token == "const" || token == "unsigned" || token == "long"/* || findCharsInString(token, "&*")*/){
type += token + " ";
token = p_parser->getNextToken();
}
......
......@@ -33,6 +33,7 @@ class HeaderParser : public PMultiFileParser{
void incrementCurrentChar();
void playOtherCode();
bool parseMacro();
bool parseDocString();
bool parseFunction(PFunction & function);
void parseTemplateDef(std::string & templateDef);
......
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