summaryrefslogtreecommitdiff
path: root/volk
diff options
context:
space:
mode:
Diffstat (limited to 'volk')
-rw-r--r--volk/CMakeLists.txt26
-rw-r--r--volk/cmake/FindORC.cmake36
-rw-r--r--volk/gen/archs.xml9
-rw-r--r--volk/gen/compilers.xml18
-rw-r--r--volk/gen/make_cpuid_c.py22
-rw-r--r--volk/lib/CMakeLists.txt213
6 files changed, 228 insertions, 96 deletions
diff --git a/volk/CMakeLists.txt b/volk/CMakeLists.txt
index 4b8fda059..fdde308ad 100644
--- a/volk/CMakeLists.txt
+++ b/volk/CMakeLists.txt
@@ -32,14 +32,32 @@ set(LIBVER 0.0.0)
set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #allows this to be a sub-project
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) #allows this to be a sub-project
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) #location for custom "Modules"
+
+########################################################################
+# Environment setup
+########################################################################
+IF(NOT DEFINED BOOST_ROOT)
+ SET(BOOST_ROOT "")
+ENDIF()
+SET(BOOST_ROOT ${BOOST_ROOT} CACHE STRING "Modify search path for Boost components")
+
+#after caching user-defined value, make sure to add the install prefix
+SET(BOOST_ROOT ${BOOST_ROOT}:${CMAKE_INSTALL_PREFIX})
+
+IF(NOT DEFINED CROSSCOMPILE_MULTILIB)
+ SET(CROSSCOMPILE_MULTILIB "")
+ENDIF()
+SET(CROSSCOMPILE_MULTILIB ${CROSSCOMPILE_MULTILIB} CACHE STRING "Define \"true\" if you have and want to use multiple C development libs installed for cross compile")
+
########################################################################
# Dependencies setup
########################################################################
-find_package(PythonInterp)
-if(NOT PYTHONINTERP_FOUND)
- message(FATAL_ERROR "Python interpreter required by the build system.")
-endif(NOT PYTHONINTERP_FOUND)
+find_package(PythonInterp REQUIRED PYTHON_EXECUTABLE)
+find_package(Boost COMPONENTS unit_test_framework)
+find_package(ORC)
+
########################################################################
# Setup the package config file
diff --git a/volk/cmake/FindORC.cmake b/volk/cmake/FindORC.cmake
new file mode 100644
index 000000000..8d8c2d13e
--- /dev/null
+++ b/volk/cmake/FindORC.cmake
@@ -0,0 +1,36 @@
+FIND_PACKAGE(PkgConfig)
+PKG_CHECK_MODULES(PC_ORC orc-0.4)
+
+
+
+
+FIND_PROGRAM(ORCC_EXECUTABLE orcc
+ HINTS ${PC_ORC_TOOLSDIR}
+ PATHS ${ORC_ROOT}/bin ${CMAKE_INSTALL_PREFIX}/bin)
+
+FIND_PATH(ORC_INCLUDE_DIR NAMES orc/orc.h
+ HINTS ${PC_ORC_INCLUDEDIR}
+ PATHS ${ORC_ROOT}/include/orc-0.4 ${CMAKE_INSTALL_PREFIX}/include/orc-0.4)
+
+
+FIND_PATH(ORC_LIBRARY_DIR NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX}
+ HINTS ${PC_ORC_LIBDIR}
+ PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
+
+FIND_LIBRARY(ORC_LIB orc-0.4
+ HINTS ${PC_ORC_LIBRARY_DIRS}
+ PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
+
+LIST(APPEND ORC_LIBRARY
+ ${ORC_LIB}
+)
+
+
+SET(ORC_INCLUDE_DIRS ${ORC_INCLUDE_DIR})
+SET(ORC_LIBRARIES ${ORC_LIBRARY})
+SET(ORC_LIBRARY_DIRS ${ORC_LIBRARY_DIR})
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ORC "orc files" ORC_LIBRARY ORC_INCLUDE_DIR ORCC_EXECUTABLE)
+
+mark_as_advanced(ICE_INCLUDE_DIR ICE_LIBRARY ORCC_EXECUTABLE)
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 960558b7c..effd90d33 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -1,8 +1,8 @@
<!-- archs appear in order of significance for blind, de-facto version ordering -->
<grammar>
-<arch name="generic" type="all">
- <flag>none</flag>
+<arch name="generic" type="all"> <!-- name and type are both required-->
+ <flag>none</flag> <!-- flag is the only required field-->
</arch>
<arch name="altivec" type="powerpc">
@@ -11,7 +11,7 @@
</arch>
<arch name="neon" type="arm">
- <flag>mfpu=neon -mfloat-abi=softfp -funsafe-math-optimizations</flag>
+ <flag>mfpu=neon,mfloat-abi=softfp,funsafe-math-optimizations</flag>
<alignment>16</alignment>
</arch>
@@ -29,7 +29,6 @@
<val>1</val>
<overrule>MD_SUBCPU</overrule>
<overrule_val>x86</overrule_val>
- <mutex>32</mutex>
</arch>
<arch name="3dnow" type="x86">
@@ -46,7 +45,7 @@
<op>0x80000001</op>
<reg>d</reg>
<shift>5</shift>
- <flag>sse4.2</flag>
+ <flag>msse4.2</flag>
<alignment>16</alignment>
</arch>
diff --git a/volk/gen/compilers.xml b/volk/gen/compilers.xml
new file mode 100644
index 000000000..70c82e555
--- /dev/null
+++ b/volk/gen/compilers.xml
@@ -0,0 +1,18 @@
+<!-- compilers remap gcc-specific information from archs.xml to specific compiler cases-->
+<grammar>
+
+<compiler name="MSVC">
+ <remap name="mmmx">arch:SSE</remap>
+ <remap name="msse">arch:SSE</remap>
+ <remap name="msse2">arch:SSE2</remap>
+ <prefix>/</prefix>
+</compiler>
+
+<compiler name="GNU">
+ <prefix>-</prefix>
+</compiler>
+
+
+
+
+</grammar> \ No newline at end of file
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index eb88dcd7f..7281f45a3 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -30,7 +30,11 @@ HEADER_TEMPL = """\
struct VOLK_CPU volk_cpu;
-#if defined(__i386__) || (__x86_64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
+# define VOLK_CPU_x86
+#endif
+
+#if defined(VOLK_CPU_x86)
//implement get cpuid for gcc compilers using a copy of cpuid.h
#if defined(__GNUC__)
@@ -40,32 +44,32 @@ struct VOLK_CPU volk_cpu;
//implement get cpuid for MSVC compilers using __cpuid intrinsic
#elif defined(_MSC_VER)
#include <intrin.h>
-#define cpuid(op, r) __cpuid(r, op)
+#define cpuid_x86(op, r) __cpuid(r, op)
#else
#error "A get cpuid for volk is not available on this compiler..."
#endif
static inline unsigned int cpuid_eax(unsigned int op) {
- unsigned int regs[4];
+ int regs[4];
cpuid_x86 (op, regs);
return regs[0];
}
static inline unsigned int cpuid_ebx(unsigned int op) {
- unsigned int regs[4];
+ int regs[4];
cpuid_x86 (op, regs);
return regs[1];
}
static inline unsigned int cpuid_ecx(unsigned int op) {
- unsigned int regs[4];
+ int regs[4];
cpuid_x86 (op, regs);
return regs[2];
}
static inline unsigned int cpuid_edx(unsigned int op) {
- unsigned int regs[4];
+ int regs[4];
cpuid_x86 (op, regs);
return regs[3];
}
@@ -103,7 +107,7 @@ def make_cpuid_c(dom) :
if no_test:
tempstring = tempstring + """\
int i_can_has_%s () {
-#if defined(__i386__) || (__x86_64__)
+#if defined(VOLK_CPU_x86)
return 1;
#else
return 0;
@@ -115,7 +119,7 @@ int i_can_has_%s () {
elif op == "1":
tempstring = tempstring + """\
int i_can_has_%s () {
-#if defined(__i386__) || (__x86_64__)
+#if defined(VOLK_CPU_x86)
unsigned int e%sx = cpuid_e%sx (%s);
return ((e%sx >> %s) & 1) == %s;
#else
@@ -128,7 +132,7 @@ int i_can_has_%s () {
elif op == "0x80000001":
tempstring = tempstring + """\
int i_can_has_%s () {
-#if defined(__i386__) || (__x86_64__)
+#if defined(VOLK_CPU_x86)
unsigned int extended_fct_count = cpuid_eax(0x80000000);
if (extended_fct_count < 0x80000001)
return %s^1;
diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt
index e18d13677..092c3ba0d 100644
--- a/volk/lib/CMakeLists.txt
+++ b/volk/lib/CMakeLists.txt
@@ -16,76 +16,141 @@
#
########################################################################
+# Setup the compiler name
+########################################################################
+set(COMPILER_NAME ${CMAKE_C_COMPILER_ID})
+if(MSVC) #its not set otherwise
+ set(COMPILER_NAME MSVC)
+endif()
+
+if(NOT DEFINED COMPILER_NAME)
+ message(FATAL_ERROR "COMPILER_NAME undefined. Volk build may not support this compiler.")
+endif()
+
+########################################################################
# Parse the arches xml file:
# Test each arch to see if the compiler supports the flag.
# If the test passes append the arch to the available list.
########################################################################
-#extract the arch lines from the xml file using crazy python
+#extract the compiler lines from the xml file using abusive python
+
+
+
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c
- "from xml.dom import minidom; print ';'.join(map(lambda a: '%s %s'%(a.attributes['name'].value,a.getElementsByTagName('flag')[0].firstChild.data),minidom.parse('${CMAKE_SOURCE_DIR}/gen/archs.xml').getElementsByTagName('arch')))"
- OUTPUT_VARIABLE arch_lines OUTPUT_STRIP_TRAILING_WHITESPACE
+ "from xml.dom import minidom; print ';'.join(map(lambda b: ','.join([','.join([b.attributes['name'].value,item.attributes['name'].value,item.firstChild.data]) for item in b.getElementsByTagName('remap')]), minidom.parse('${CMAKE_SOURCE_DIR}/gen/compilers.xml').getElementsByTagName('compiler')))"
+
+ OUTPUT_VARIABLE compiler_lines OUTPUT_STRIP_TRAILING_WHITESPACE
)
-#get any mutually exclusive archs so we can exclude them
-#this is really for compilers which can do both 32- and 64-bit compilations.
+foreach(thing ${compiler_lines})
+ string(REGEX REPLACE "," ";" thing_list ${thing})
+ list(FIND thing_list ${COMPILER_NAME} check_val)
+ if(NOT ("${check_val}" STREQUAL "-1"))
+ string(REGEX REPLACE "${COMPILER_NAME}," ";" filter_string ${thing})
+ endif()
+endforeach()
+
+
+#extract compiler prefixes from the xml file using abusive python
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c
- "from xml.dom import minidom; print ';'.join(map(lambda a: '%s %s'%(a.parentNode.attributes['name'].value,a.firstChild.data),minidom.parse('${CMAKE_SOURCE_DIR}/gen/archs.xml').getElementsByTagName('mutex')))"
- OUTPUT_VARIABLE mutex_lines OUTPUT_STRIP_TRAILING_WHITESPACE
+ "from xml.dom import minidom; print ';'.join(map(lambda b: ','.join([','.join([b.attributes['name'].value,item.firstChild.data]) for item in b.getElementsByTagName('prefix')]), minidom.parse('${CMAKE_SOURCE_DIR}/gen/compilers.xml').getElementsByTagName('compiler')))"
+
+ OUTPUT_VARIABLE compiler_prefixes OUTPUT_STRIP_TRAILING_WHITESPACE
)
-#This macro sets the ${arch}_flag variable,
-#and handles special cases for MSVC arch flags.
-macro(set_arch_flag name flag)
- if(MSVC AND ${name} STREQUAL "mmx")
- set(${name}_flag "/arch:SSE") #no /arch:MMX
- elseif(MSVC AND ${name} STREQUAL "sse")
- set(${name}_flag "/arch:SSE")
- elseif(MSVC AND ${name} STREQUAL "sse2")
- set(${name}_flag "/arch:SSE2")
- else()
- set(${name}_flag -${flag})
+foreach(thing ${compiler_prefixes})
+ string(REGEX REPLACE "," ";" thing_list ${thing})
+ list(FIND thing_list ${COMPILER_NAME} check_val)
+ if(NOT ("${check_val}" STREQUAL "-1"))
+ list(GET thing_list "1" prefix)
endif()
-endmacro(set_arch_flag)
+endforeach()
+
+
+
+
+#extract the arch lines from the xml file using abusive python
+execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c
+ "from xml.dom import minidom; print ';'.join(map(lambda a: '%s %s %s %s'%(a.attributes['name'].value,a.getElementsByTagName('flag')[0].firstChild.data,a.getElementsByTagName('overrule')[0].firstChild.data,a.getElementsByTagName('overrule_val')[0].firstChild.data) if (len(a.getElementsByTagName('overrule'))) else '%s %s %s %s'%(a.attributes['name'].value,a.getElementsByTagName('flag')[0].firstChild.data,'no_overrule', 'no_overrule_val'), minidom.parse('${CMAKE_SOURCE_DIR}/gen/archs.xml').getElementsByTagName('arch')))"
+
+ OUTPUT_VARIABLE arch_lines OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+
+
+
+#set the various overrule values (see archs.xml)
+#a lot of this is translating between automake and cmake
+if(NOT "${CROSSCOMPILE_MULTILIB}" STREQUAL "true")
+ set(MD_SUBCPU ${CMAKE_HOST_SYSTEM_PROCESSOR})
+endif()
+if(NOT "${ORC_FOUND}" STREQUAL "TRUE")
+ set(LV_HAVE_ORC "no")
+endif()
+
+
+
-macro(handle_arch name flag)
+
+macro(compiler_filter name flag)
+ set(filtered_flag ${flag})
+ foreach(thing ${filter_string})
+ string(REGEX REPLACE "," ";" flagmap ${thing})
+ list(GET flagmap "0" key)
+ list(GET flagmap "1" val)
+ string(REGEX MATCH "^${key}$" found ${flag})
+ if("${found}" STREQUAL "${key}")
+ string(REGEX REPLACE "^${key}$" "${val}" filtered_flag ${flag})
+ endif()
+ endforeach()
+ set(${name}_flag "${prefix}${filtered_flag}")
+endmacro()
+
+
+
+
+
+
+
+macro(handle_arch name flag overrule overrule_val)
+
+ #handle overrule
+ if("${${overrule}}" STREQUAL "${overrule_val}")
+ set(have_${name} FALSE)
+ message(STATUS "${name} overruled")
#handle special case for none flag
- if(${flag} STREQUAL "none")
+ elseif(${flag} STREQUAL "none")
set(have_${name} TRUE)
-
- #otherwise test the flag against the compiler
+ #otherwise test the flag(s) against the compiler
else()
include(CheckCXXCompilerFlag)
- set_arch_flag(${name} ${flag})
- CHECK_CXX_COMPILER_FLAG(${${name}_flag} have_${name})
+ string(REGEX REPLACE "," ";" flag_list ${flag})
+ set(have_${name} 1)
+ foreach(thing ${flag_list})
+ compiler_filter(${name} ${thing})
+ CHECK_CXX_COMPILER_FLAG(${${name}_flag} have_${thing})
+ if(NOT (${have_${name}} AND ("${have_${thing}}" STREQUAL "1")))
+ set(have_${name} 0)
+ endif()
+ endforeach()
endif()
if(have_${name})
list(APPEND available_arches ${name})
endif()
-endmacro(handle_arch)
-macro(remove_mutex name mutex)
- if(have_${name})
- unset(have_${mutex})
- endif()
- list(REMOVE_ITEM available_arches ${mutex})
-endmacro(remove_mutex)
+endmacro(handle_arch)
#create a list of available arches
foreach(arch_line ${arch_lines})
- separate_arguments(args UNIX_COMMAND "${arch_line}")
+ string(REPLACE " " ";" args "${arch_line}")
handle_arch(${args})
endforeach(arch_line)
-#strip out mutex archs
-foreach(mutex_line ${mutex_lines})
- separate_arguments(args UNIX_COMMAND "${mutex_line}")
- remove_mutex(${args})
-endforeach(mutex_line)
-
message(STATUS "Available arches: ${available_arches}")
########################################################################
@@ -114,10 +179,12 @@ macro(handle_machine1 name)
set(machine_flags "${machine_flags} ${${arch}_flag}")
endforeach(arch)
+ string(REGEX REPLACE "^[ \t]+" "" machine_flags "${machine_flags}")
+
if(is_match)
#this is a match, append the source and set its flags
set(machine_source ${CMAKE_CURRENT_BINARY_DIR}/volk_machine_${name}.c)
- set_source_files_properties(${machine_source} PROPERTIES COMPILE_FLAGS ${machine_flags})
+ set_source_files_properties(${machine_source} PROPERTIES COMPILE_FLAGS "${machine_flags}")
list(APPEND machine_sources ${machine_source})
list(APPEND machine_defs ${machine_def})
list(APPEND available_machines ${name})
@@ -138,7 +205,7 @@ endmacro(handle_machine)
#setup the available machines
foreach(machine_line ${machine_lines})
- separate_arguments(args UNIX_COMMAND "${machine_line}")
+ string(REPLACE " " ";" args "${machine_line}")
handle_machine(${args})
endforeach(machine_line)
@@ -168,20 +235,10 @@ file(GLOB xml_files ${CMAKE_SOURCE_DIR}/gen/*.xml)
file(GLOB py_files ${CMAKE_SOURCE_DIR}/gen/*.py)
file(GLOB h_files ${CMAKE_SOURCE_DIR}/include/volk/*.h)
-#make sure we can use -B with python (introduced in 2.6)
-execute_process(
- COMMAND ${PYTHON_EXECUTABLE} -B -c ""
- OUTPUT_QUIET ERROR_QUIET
- RESULT_VARIABLE PYTHON_HAS_DASH_B_RESULT
-)
-if(PYTHON_HAS_DASH_B_RESULT EQUAL 0)
- set(PYTHON_DASH_B "-B")
-endif()
-
add_custom_command(
OUTPUT ${volk_gen_sources}
DEPENDS ${xml_files} ${py_files} ${h_files}
- COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ COMMAND ${PYTHON_EXECUTABLE} -B
${CMAKE_SOURCE_DIR}/gen/volk_register.py
${CMAKE_BINARY_DIR}
)
@@ -189,14 +246,12 @@ add_custom_command(
########################################################################
# Handle orc support
########################################################################
-find_package(PkgConfig)
-if(PKG_CONFIG_FOUND)
-PKG_CHECK_MODULES(ORC "orc-0.4 > 0.4.11")
-endif(PKG_CONFIG_FOUND)
-find_program(ORCC_EXECUTABLE orcc)
-if(ORC_FOUND AND ORCC_EXECUTABLE)
+
+
+
+if(ORC_FOUND)
#setup orc library usage
include_directories(${ORC_INCLUDE_DIRS})
link_directories(${ORC_LIBRARY_DIRS})
@@ -225,16 +280,15 @@ endif()
########################################################################
# Setup the volk sources list and library
########################################################################
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
- #http://gcc.gnu.org/wiki/Visibility
+if(NOT WIN32)
add_definitions(-fvisibility=hidden)
endif()
include_directories(
- ${CMAKE_BINARY_DIR}/include
${CMAKE_SOURCE_DIR}/include
- ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
)
list(APPEND volk_sources
@@ -254,11 +308,13 @@ if(MSVC)
include_directories(${CMAKE_SOURCE_DIR}/msvc)
#compile the sources as C++ due to the lack of complex.h under MSVC
set_source_files_properties(${volk_sources} PROPERTIES LANGUAGE CXX)
-endif(MSVC)
+endif()
#create the volk runtime library
add_library(volk SHARED ${volk_sources})
-target_link_libraries(volk ${ORC_LIBRARIES})
+if(ORC_FOUND)
+ target_link_libraries(volk ${ORC_LIBRARIES})
+endif(ORC_FOUND)
set_target_properties(volk PROPERTIES SOVERSION ${LIBVER})
set_target_properties(volk PROPERTIES DEFINE_SYMBOL "volk_EXPORTS")
@@ -271,23 +327,24 @@ install(TARGETS volk
########################################################################
# Build the QA test application
########################################################################
-find_package(Boost COMPONENTS unit_test_framework)
+
if(Boost_FOUND)
-set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc PROPERTIES
- COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK;BOOST_TEST_MAIN"
-)
+ set_source_files_properties(
+ ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc PROPERTIES
+ COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK;BOOST_TEST_MAIN"
+ )
-include_directories(${Boost_INCLUDE_DIRS})
-link_directories(${Boost_LIBRARY_DIRS})
+ include_directories(${Boost_INCLUDE_DIRS})
+ link_directories(${Boost_LIBRARY_DIRS})
-add_executable(test_all
- ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc
-)
-target_link_libraries(test_all volk ${Boost_LIBRARIES})
-#ADD_TEST(qa_volk_test_all test_all)
+ add_executable(test_all
+ ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc
+ )
+ target_link_libraries(test_all volk ${Boost_LIBRARIES})
+ add_test(qa_volk_test_all test_all)
+
+endif(Boost_FOUND)
-endif()