diff options
author | Josh Blum | 2012-04-16 00:29:26 -0700 |
---|---|---|
committer | Josh Blum | 2012-04-19 18:12:55 -0700 |
commit | 3af0f815ae3442dacdac78acf238b277f472c404 (patch) | |
tree | 88c237c7f036a1417399d654382bb6971d445164 | |
parent | 37f9a62fd45ece1e6a92769fbb1798403c86ba9b (diff) | |
download | gnuradio-3af0f815ae3442dacdac78acf238b277f472c404.tar.gz gnuradio-3af0f815ae3442dacdac78acf238b277f472c404.tar.bz2 gnuradio-3af0f815ae3442dacdac78acf238b277f472c404.zip |
volk: added compile utils and cleanup cmakelists
-rw-r--r-- | volk/gen/machines.xml | 19 | ||||
-rw-r--r-- | volk/gen/volk_arch_defs.py | 3 | ||||
-rw-r--r-- | volk/gen/volk_compile_utils.py | 68 | ||||
-rw-r--r-- | volk/gen/volk_machine_defs.py | 7 | ||||
-rw-r--r-- | volk/lib/CMakeLists.txt | 258 | ||||
-rwxr-xr-x | volk/libvector_replace.sh | 18 | ||||
-rw-r--r-- | volk/python/__init__.py | 53 | ||||
-rwxr-xr-x | volk/python/qa_square.py | 47 | ||||
-rw-r--r-- | volk/python/volk.i | 47 | ||||
-rw-r--r-- | volk/python/volk_square_ff.i | 37 | ||||
-rw-r--r-- | volk/tmpl/volk_cpu.tmpl.c | 32 | ||||
-rw-r--r-- | volk/tmpl/volk_machine_xxx.tmpl.c | 2 |
12 files changed, 179 insertions, 412 deletions
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml index 9c19c91c6..04ffef22b 100644 --- a/volk/gen/machines.xml +++ b/volk/gen/machines.xml @@ -10,27 +10,17 @@ </machine> <machine name="sse"> -<archs>generic 32|64 mmx sse</archs> +<archs>generic 32|64| mmx sse</archs> </machine> --> -<!-- -Create an SSE2 and AVX only machine (without 64/32 inline assembly support). -This machine is intended to support the MSVC compiler on x86/amd64. -The MSVC compiler has intrinsic support for SSE, SSE2, AVX -however it does not support the gcc style inline assembly. ---> - <machine name="neon"> <archs>generic neon</archs> </machine> -<machine name="sse2_only"> -<archs>generic mmx sse sse2</archs> -</machine> - +<!-- trailing | bar means generate without either for MSVC --> <machine name="sse2"> -<archs>generic 32|64 mmx sse sse2</archs> +<archs>generic 32|64| mmx sse sse2</archs> </machine> <machine name="sse3"> @@ -53,8 +43,9 @@ however it does not support the gcc style inline assembly. <archs>generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount</archs> </machine> +<!-- trailing | bar means generate without either for MSVC --> <machine name="avx"> -<archs>generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx</archs> +<archs>generic 32|64| mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx</archs> </machine> <machine name="avx_only"> diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py index d29a951eb..4f4796840 100644 --- a/volk/gen/volk_arch_defs.py +++ b/volk/gen/volk_arch_defs.py @@ -40,6 +40,9 @@ class arch_class: except: setattr(self, key, failval) assert(self.name) assert(self.type) + if self.flag == 'none': self.flag = None + self.flags = list() + if self.flag: self.flags = map(str.strip, self.flag.split(',')) def __repr__(self): return self.name diff --git a/volk/gen/volk_compile_utils.py b/volk/gen/volk_compile_utils.py new file mode 100644 index 000000000..a62c5657e --- /dev/null +++ b/volk/gen/volk_compile_utils.py @@ -0,0 +1,68 @@ +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import optparse +import volk_arch_defs +import volk_machine_defs + +def format_flag(flag, compiler): + if compiler == 'msvc' and flag in ('mmmx', 'msse'): + return '/arch:SSE' + if compiler == 'msvc' and flag in ('msse2',): + return '/arch:SSE2' + if compiler == 'msvc' and flag in ('msse3', 'mssse3', 'msse4.1', 'msse4.2', 'mpopcnt', 'mavx'): + return '/arch:AVX' + #otherwise its a gcc compiler + return '-' + flag + +def do_arch_flags_list(compiler): + output = list() + for arch in volk_arch_defs.archs: + fields = [arch.name] + fields += list(map(lambda f: format_flag(f, compiler), arch.flags)) + output.append(','.join(fields)) + print ';'.join(output) + +def do_machines_list(arch_names): + output = list() + for machine in volk_machine_defs.machines: + machine_arch_set = set(machine.arch_names) + if set(arch_names).intersection(machine_arch_set) == machine_arch_set: + output.append(machine.name) + print ';'.join(output) + +def do_machine_flags_list(compiler, machine_name): + output = list() + machine = volk_machine_defs.machine_dict[machine_name] + for arch in machine.archs: + for flag in arch.flags: + output.append(format_flag(flag, compiler)) + print ' '.join(output) + +def main(): + parser = optparse.OptionParser() + parser.add_option('--mode', type='string', default='') + parser.add_option('--compiler', type='string', default='') + parser.add_option('--archs', type='string', default='') + parser.add_option('--machine', type='string', default='') + (opts, args) = parser.parse_args() + + if opts.mode == 'arch_flags': return do_arch_flags_list(opts.compiler.lower()) + if opts.mode == 'machines': return do_machines_list(opts.archs.split(';')) + if opts.mode == 'machine_flags': return do_machine_flags_list(opts.compiler.lower(), opts.machine) + +if __name__ == '__main__': main() diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py index 82734679c..b30a480ba 100644 --- a/volk/gen/volk_machine_defs.py +++ b/volk/gen/volk_machine_defs.py @@ -24,10 +24,12 @@ class machine_class: def __init__(self, name, archs): self.name = name self.archs = list() + self.arch_names = list() for arch_name in archs: if not arch_name: continue arch = arch_dict[arch_name] self.archs.append(arch) + self.arch_names.append(arch_name) arch_name += '_u' if arch.alignment > 1 and arch_dict.has_key(arch_name): arch = arch_dict[arch_name] @@ -40,7 +42,10 @@ def register_machine(name, archs): for i, arch_name in enumerate(archs): if '|' in arch_name: #handle special arch names with the '|' for arch_sub in arch_name.split('|'): - register_machine(name+'_'+arch_sub, archs[:i] + [arch_sub] + archs[i+1:]) + if arch_sub: + register_machine(name+'_'+arch_sub, archs[:i] + [arch_sub] + archs[i+1:]) + else: + register_machine(name, archs[:i] + archs[i+1:]) return machine = machine_class(name=name, archs=archs) machines.append(machine) diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt index c6187f35d..b45f89d02 100644 --- a/volk/lib/CMakeLists.txt +++ b/volk/lib/CMakeLists.txt @@ -16,6 +16,20 @@ # ######################################################################## +# header file detection +######################################################################## +include(CheckIncludeFile) +CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H) +if(HAVE_CPUID_H) + add_definitions(-DHAVE_CPUID_H) +endif() + +CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H) +if(HAVE_INTRIN_H) + add_definitions(-DHAVE_INTRIN_H) +endif() + +######################################################################## # Setup the compiler name ######################################################################## set(COMPILER_NAME ${CMAKE_C_COMPILER_ID}) @@ -28,199 +42,81 @@ if(NOT DEFINED COMPILER_NAME) 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. +# determine passing architectures based on compile flag tests ######################################################################## -#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 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 + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/gen/volk_compile_utils.py + --mode "arch_flags" --compiler "${COMPILER_NAME}" + OUTPUT_VARIABLE arch_flag_lines OUTPUT_STRIP_TRAILING_WHITESPACE ) -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 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 -) - -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() -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_SYSTEM_PROCESSOR}) - #detect 32 or 64 bit compiler - if(MD_SUBCPU MATCHES "^(i.86|x86|x86_64|amd64)$") - include(CheckTypeSize) - check_type_size("void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY) - if (${SIZEOF_VOID_P} EQUAL 8) - set(MD_SUBCPU x86_64) - else() - set(MD_SUBCPU x86) +macro(check_arch arch_name) + set(flags ${ARGN}) + set(have_${arch_name} TRUE) + foreach(flag ${flags}) + include(CheckCXXCompilerFlag) + set(have_flag have_${flag}) + CHECK_CXX_COMPILER_FLAG(${flag} ${have_flag}) + if (NOT ${have_flag}) + set(have_${arch_name} FALSE) endif() + endforeach(flag) + if (have_${arch_name}) + list(APPEND available_archs ${arch_name}) endif() -endif() -if(NOT "${ORC_FOUND}" STREQUAL "TRUE") - set(LV_HAVE_ORC "no") -endif() - - - - - - -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() +endmacro(check_arch) +foreach(line ${arch_flag_lines}) + string(REGEX REPLACE "," ";" arch_flags ${line}) + check_arch(${arch_flags}) +endforeach(line) +######################################################################## +# implement overruling in the non-multilib case +# this makes things work when both -m32 and -m64 pass +######################################################################## +if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64)$") + message(STATUS "x86* CPU detected") + set(CPU_IS_x86 TRUE) +endif() - - - - -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 - elseif(${flag} STREQUAL "none") - set(have_${name} TRUE) - #otherwise test the flag(s) against the compiler - else() - include(CheckCXXCompilerFlag) - 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() +if(NOT CROSSCOMPILE_MULTILIB AND CPU_IS_x86) + include(CheckTypeSize) + check_type_size("void*[8]" SIZEOF_CPU BUILTIN_TYPES_ONLY) + message(STATUS "CPU width ${SIZEOF_CPU} bits") + if (${SIZEOF_CPU} EQUAL 64) + message(STATUS "Overruled arch 32") + list(REMOVE_ITEM available_archs 32) endif() - - if(have_${name}) - list(APPEND available_arches ${name}) + if (${SIZEOF_CPU} EQUAL 32) + message(STATUS "Overruled arch 64") + list(REMOVE_ITEM available_archs 64) endif() +endif() -endmacro(handle_arch) - -#create a list of available arches -foreach(arch_line ${arch_lines}) - string(REPLACE " " ";" args "${arch_line}") - handle_arch(${args}) -endforeach(arch_line) - -message(STATUS "Available arches: ${available_arches}") +message(STATUS "Available architectures: ${available_archs}") ######################################################################## -# Parse the machines xml file: -# Test each machine to see if its arch dependencies are supported. -# Build a list of supported machines and the machine definitions. +# determine available machines given the available architectures ######################################################################## -#extract the machine lines from the xml file using crazy 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('archs')[0].firstChild.data),minidom.parse('${CMAKE_SOURCE_DIR}/gen/machines.xml').getElementsByTagName('machine')))" - OUTPUT_VARIABLE machine_lines OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/gen/volk_compile_utils.py + --mode "machines" --archs "${available_archs}" + OUTPUT_VARIABLE available_machines OUTPUT_STRIP_TRAILING_WHITESPACE ) -macro(handle_machine1 name) - unset(machine_flags) - string(TOUPPER LV_MACHINE_${name} machine_def) - - #check if all the arches are supported - foreach(arch ${ARGN}) - set(is_match ${have_${arch}}) - if(NOT is_match) - set(is_match FALSE) - break() - endif(NOT is_match) - 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}") - list(APPEND machine_sources ${machine_source}) - list(APPEND machine_defs ${machine_def}) - list(APPEND available_machines ${name}) - endif() -endmacro(handle_machine1) - -macro(handle_machine name) - set(arches ${ARGN}) - list(FIND arches "32|64" index) - if(${index} EQUAL -1) - handle_machine1(${name} ${arches}) - else() - list(REMOVE_ITEM arches "32|64") - handle_machine1(${name}_32 32 ${arches}) - handle_machine1(${name}_64 64 ${arches}) - endif() -endmacro(handle_machine) - -#setup the available machines -foreach(machine_line ${machine_lines}) - string(REPLACE " " ";" args "${machine_line}") - handle_machine(${args}) -endforeach(machine_line) - message(STATUS "Available machines: ${available_machines}") +foreach(machine_name ${available_machines}) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/gen/volk_compile_utils.py + --mode "machine_flags" --machine "${machine_name}" --compiler "${COMPILER_NAME}" + OUTPUT_VARIABLE ${machine_name}_flags OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(TOUPPER LV_MACHINE_${machine_name} machine_def) + list(APPEND machine_defs ${machine_def}) +endforeach(machine_name) + ######################################################################## # Create rules to run the volk generator ######################################################################## @@ -238,6 +134,8 @@ macro(gen_template tmpl output) ) endmacro(gen_template) +make_directory(${CMAKE_BINARY_DIR}/include/volk) + gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk.tmpl.h ${CMAKE_BINARY_DIR}/include/volk/volk.h) gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk.tmpl.c ${CMAKE_BINARY_DIR}/lib/volk.c) gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_typedefs.tmpl.h ${CMAKE_BINARY_DIR}/include/volk/volk_typedefs.h) @@ -247,13 +145,13 @@ gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_config_fixed.tmpl.h ${CMAKE_BINARY_DI gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_machines.tmpl.h ${CMAKE_BINARY_DIR}/lib/volk_machines.h) gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_machines.tmpl.c ${CMAKE_BINARY_DIR}/lib/volk_machines.c) -foreach(name ${available_machines}) - gen_template( - ${CMAKE_SOURCE_DIR}/tmpl/volk_machine_xxx.tmpl.c - ${CMAKE_CURRENT_BINARY_DIR}/volk_machine_${name}.c - ${name} - ) -endforeach(name) +foreach(machine_name ${available_machines}) + set(machine_source ${CMAKE_CURRENT_BINARY_DIR}/volk_machine_${machine_name}.c) + gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_machine_xxx.tmpl.c ${machine_source} ${machine_name}) + if(${machine_name}_flags) + set_source_files_properties(${machine_source} PROPERTIES COMPILE_FLAGS "${${machine_name}_flags}") + endif() +endforeach(machine_name) ######################################################################## # Set local include directories first diff --git a/volk/libvector_replace.sh b/volk/libvector_replace.sh deleted file mode 100755 index e1940c00f..000000000 --- a/volk/libvector_replace.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -cd $1 -files=`ls` -for file in $files -do - sed 's/libvector/volk/g' < $file > tempfile - sed 's/LIBVECTOR/VOLK/g' < tempfile > $file -done -for file in $files -do - echo $file > tempfile - newfile=`sed 's/libvector/volk/g' < tempfile` - if (test "$file" != "$newfile"); then - mv $file $newfile - echo "changed $file to $newfile" - fi -done diff --git a/volk/python/__init__.py b/volk/python/__init__.py deleted file mode 100644 index 7c9c4a0c6..000000000 --- a/volk/python/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# -# Copyright 2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -# The presence of this file turns this directory into a Python package - -# ---------------------------------------------------------------- -# Temporary workaround for ticket:181 (swig+python problem) -import sys -_RTLD_GLOBAL = 0 -try: - from dl import RTLD_GLOBAL as _RTLD_GLOBAL -except ImportError: - try: - from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL - except ImportError: - pass - -if _RTLD_GLOBAL != 0: - _dlopenflags = sys.getdlopenflags() - sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) -# ---------------------------------------------------------------- - - -# import swig generated symbols into the volk namespace -from volk_swig import * - -# import any pure python here -# from volk_foo import bar -# from volk_baz import * - - -# ---------------------------------------------------------------- -# Tail of workaround -if _RTLD_GLOBAL != 0: - sys.setdlopenflags(_dlopenflags) # Restore original flags -# ---------------------------------------------------------------- diff --git a/volk/python/qa_square.py b/volk/python/qa_square.py deleted file mode 100755 index c74bc25ef..000000000 --- a/volk/python/qa_square.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import volk_swig as volk - -class qa_volk(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_001_square_ff(self): - src_data = (-3, 4, -5.5, 2, 3) - expected_result = (9, 16, 30.25, 4, 9) - src = gr.vector_source_f(src_data) - sqr = volk.square_ff() - dst = gr.vector_sink_f() - self.tb.connect(src, sqr) - self.tb.connect(sqr, dst) - self.tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual(expected_result, result_data, 6) - -if __name__ == '__main__': - gr_unittest.main() diff --git a/volk/python/volk.i b/volk/python/volk.i deleted file mode 100644 index d678a9120..000000000 --- a/volk/python/volk.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -%feature("autodoc", "1"); // generate python docstrings - -%include "exception.i" -%import "gnuradio.i" // the common stuff - -%{ -#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix -#include <stdexcept> -%} - -// ---------------------------------------------------------------- - -/* - * Gather all .i files in this directory together. - */ - -%{ - -// The .h files -#include <volk/volk_square_ff.h> - -%} - -// The .i files -%include <volk_square_ff.i> - diff --git a/volk/python/volk_square_ff.i b/volk/python/volk_square_ff.i deleted file mode 100644 index 5456c81fd..000000000 --- a/volk/python/volk_square_ff.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * First arg is the package prefix. - * Second arg is the name of the class minus the prefix. - * - * This does some behind-the-scenes magic so we can - * access gr_example_square_ff from python as howto.square_ff - */ -GR_SWIG_BLOCK_MAGIC(volk,square_ff); - -volk_square_ff_sptr volk_make_square_ff (); - -class volk_square_ff : public gr_sync_block -{ -private: - volk_square_ff(); -}; diff --git a/volk/tmpl/volk_cpu.tmpl.c b/volk/tmpl/volk_cpu.tmpl.c index c278afc2e..7fe7036e2 100644 --- a/volk/tmpl/volk_cpu.tmpl.c +++ b/volk/tmpl/volk_cpu.tmpl.c @@ -25,23 +25,27 @@ struct VOLK_CPU volk_cpu; #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) -# define VOLK_CPU_x86 + #define VOLK_CPU_x86 #endif #if defined(VOLK_CPU_x86) -//implement get cpuid for gcc compilers using a copy of cpuid.h +//implement get cpuid for gcc compilers using a system or local copy of cpuid.h #if defined(__GNUC__) -#include <gcc_x86_cpuid.h> -#define cpuid_x86(op, r) __get_cpuid(op, (unsigned int *)r+0, (unsigned int *)r+1, (unsigned int *)r+2, (unsigned int *)r+3) + #if defined(HAVE_CPUID_H) + #include <cpuid.h> + #else + #include "gcc_x86_cpuid.h" + #endif + #define cpuid_x86(op, r) __get_cpuid(op, (unsigned int *)r+0, (unsigned int *)r+1, (unsigned int *)r+2, (unsigned int *)r+3) //implement get cpuid for MSVC compilers using __cpuid intrinsic -#elif defined(_MSC_VER) -#include <intrin.h> -#define cpuid_x86(op, r) __cpuid(r, op) +#elif defined(_MSC_VER) && defined(HAVE_INTRIN_H) + #include <intrin.h> + #define cpuid_x86(op, r) __cpuid(r, op) #else -#error "A get cpuid for volk is not available on this compiler..." + #error "A get cpuid for volk is not available on this compiler..." #endif static inline unsigned int cpuid_eax(unsigned int op) { @@ -69,15 +73,16 @@ static inline unsigned int cpuid_edx(unsigned int op) { } #endif +//neon detection is linux specific #if defined(__arm__) && defined(__linux__) -#include <asm/hwcap.h> -#include <linux/auxvec.h> -#include <stdio.h> -#define LOOK_FOR_NEON + #include <asm/hwcap.h> + #include <linux/auxvec.h> + #include <stdio.h> + #define VOLK_CPU_ARM #endif static int has_neon(void){ -#if defined(LOOK_FOR_NEON) +#if defined(VOLK_CPU_ARM) FILE *auxvec_f; unsigned long auxvec[2]; unsigned int found_neon = 0; @@ -94,7 +99,6 @@ static int has_neon(void){ fclose(auxvec_f); return found_neon; - #else return 0; #endif diff --git a/volk/tmpl/volk_machine_xxx.tmpl.c b/volk/tmpl/volk_machine_xxx.tmpl.c index 87204ee99..023eea502 100644 --- a/volk/tmpl/volk_machine_xxx.tmpl.c +++ b/volk/tmpl/volk_machine_xxx.tmpl.c @@ -20,7 +20,7 @@ */ #set $this_machine = $machine_dict[$which] -#set $arch_names = map(lambda a: a.name, $this_machine.archs) +#set $arch_names = $this_machine.arch_names #for $arch in $this_machine.archs #define LV_HAVE_$(arch.name.upper()) 1 |