Fixed VOLK compilation issue #16

master
ismagom 11 years ago
parent 04172989e7
commit 8bed6caf4f

@ -0,0 +1,25 @@
#ifdef CHECK_FUNCTION_EXISTS
char CHECK_FUNCTION_EXISTS();
#ifdef __CLASSIC_C__
int main(){
int ac;
char*av[];
#else
int main(int ac, char*av[]){
#endif
float ac2 = sqrtf(rand());
CHECK_FUNCTION_EXISTS();
if(ac2 * ac > 1000)
{
return *av[0];
}
return 0;
}
#else /* CHECK_FUNCTION_EXISTS */
# error "CHECK_FUNCTION_EXISTS has to specify the function"
#endif /* CHECK_FUNCTION_EXISTS */

@ -0,0 +1,57 @@
# - Check if a C function can be linked
# CHECK_FUNCTION_EXISTS(<function> <variable>)
#
# Check that the <function> is provided by libraries on the system and
# store the result in a <variable>. This does not verify that any
# system header file declares the function, only that it can be found
# at link time (considure using CheckSymbolExists).
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
MACRO(CHECK_FUNCTION_EXISTS_MATH FUNCTION VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
MESSAGE(STATUS "Looking for ${FUNCTION}")
IF(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ELSE(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
ENDIF(CMAKE_REQUIRED_LIBRARIES)
IF(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
ELSE(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES)
ENDIF(CMAKE_REQUIRED_INCLUDES)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/cmake/modules/CheckFunctionExists.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}"
"${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
IF(${VARIABLE})
SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
MESSAGE(STATUS "Looking for ${FUNCTION} - found")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the function ${FUNCTION} exists passed with the following output:\n"
"${OUTPUT}\n\n")
ELSE(${VARIABLE})
MESSAGE(STATUS "Looking for ${FUNCTION} - not found")
SET(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the function ${FUNCTION} exists failed with the following output:\n"
"${OUTPUT}\n\n")
ENDIF(${VARIABLE})
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
ENDMACRO(CHECK_FUNCTION_EXISTS_MATH)

@ -24,6 +24,36 @@ FIND_LIBRARY(
/usr/lib64 /usr/lib64
) )
# Some functions are not defined in old volk versions
SET(CMAKE_REQUIRED_LIBRARIES volk m)
CHECK_FUNCTION_EXISTS_MATH(volk_32f_index_max_16u HAVE_VOLK_MAX_FUNCTION)
CHECK_FUNCTION_EXISTS_MATH(volk_32f_accumulator_s32f HAVE_VOLK_ACC_FUNCTION)
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_s32fc_multiply_32fc HAVE_VOLK_MULT_FUNCTION)
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_conjugate_32fc HAVE_VOLK_CONJ_FUNCTION)
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_x2_multiply_32fc HAVE_VOLK_MULT2_FUNCTION)
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_magnitude_32f HAVE_VOLK_MAG_FUNCTION)
SET(VOLK_DEFINITIONS "HAVE_VOLK")
IF(${HAVE_VOLK_MAX_FUNCTION})
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_FUNCTION")
ENDIF()
IF(${HAVE_VOLK_ACC_FUNCTION})
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_ACC_FUNCTION")
ENDIF()
IF(${HAVE_VOLK_MULT_FUNCTION})
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MULT_FUNCTION")
ENDIF()
IF(${HAVE_VOLK_CONJ_FUNCTION})
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_CONJ_FUNCTION")
ENDIF()
IF(${HAVE_VOLK_MULT2_FUNCTION})
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MULT2_FUNCTION")
ENDIF()
IF(${HAVE_VOLK_MAG_FUNCTION})
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAG_FUNCTION")
ENDIF()
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VOLK DEFAULT_MSG VOLK_LIBRARIES VOLK_INCLUDE_DIRS) FIND_PACKAGE_HANDLE_STANDARD_ARGS(VOLK DEFAULT_MSG VOLK_LIBRARIES VOLK_INCLUDE_DIRS)
MARK_AS_ADVANCED(VOLK_LIBRARIES VOLK_INCLUDE_DIRS) MARK_AS_ADVANCED(VOLK_LIBRARIES VOLK_INCLUDE_DIRS VOLK_DEFINITIONS)

@ -23,6 +23,7 @@
######################################################################## ########################################################################
# Find Dependencies # Find Dependencies
######################################################################## ########################################################################
include(CheckFunctionExistsMath)
FIND_PACKAGE(FFTW3F REQUIRED) # TODO: distribute kissfft instead FIND_PACKAGE(FFTW3F REQUIRED) # TODO: distribute kissfft instead
INCLUDE_DIRECTORIES(${FFTW3F_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${FFTW3F_INCLUDE_DIRS})
@ -57,9 +58,9 @@ LIBLTE_SET_PIC(lte)
IF(VOLK_FOUND) IF(VOLK_FOUND)
INCLUDE_DIRECTORIES(${VOLK_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${VOLK_INCLUDE_DIRS})
SET_TARGET_PROPERTIES(lte PROPERTIES COMPILE_DEFINITIONS "HAVE_VOLK") SET_TARGET_PROPERTIES(lte PROPERTIES COMPILE_DEFINITIONS "${VOLK_DEFINITIONS}")
TARGET_LINK_LIBRARIES(lte ${VOLK_LIBRARIES}) TARGET_LINK_LIBRARIES(lte ${VOLK_LIBRARIES})
MESSAGE(STATUS " Compiling with VOLK SIMD library.") MESSAGE(STATUS " Compiling with VOLK SIMD library.")
ELSE(VOLK_FOUND) ELSE(VOLK_FOUND)
MESSAGE(STATUS " VOLK SIMD library NOT found. Using generic implementation.") MESSAGE(STATUS " VOLK SIMD library NOT found. Using generic implementation.")
ENDIF(VOLK_FOUND) ENDIF(VOLK_FOUND)

@ -93,6 +93,9 @@ int regs_phich_init(regs_t *h) {
case R_2: case R_2:
ng = 2; ng = 2;
break; break;
default:
ng = 0;
break;
} }
h->ngroups_phich = (int) ceilf(ng * ((float) h->nof_prb/8)); h->ngroups_phich = (int) ceilf(ng * ((float) h->nof_prb/8));
h->phich = malloc(sizeof(regs_ch_t) * h->ngroups_phich); h->phich = malloc(sizeof(regs_ch_t) * h->ngroups_phich);

@ -45,17 +45,17 @@ int vec_acc_ii(int *x, int len) {
} }
float vec_acc_ff(float *x, int len) { float vec_acc_ff(float *x, int len) {
#ifndef HAVE_VOLK #ifdef HAVE_VOLK_ACC_FUNCTION
float result;
volk_32f_accumulator_s32f_u(&result,x,(unsigned int) len);
return result;
#else
int i; int i;
float z=0; float z=0;
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
z+=x[i]; z+=x[i];
} }
return z; return z;
#else
float result;
volk_32f_accumulator_s32f_u(&result,x,(unsigned int) len);
return result;
#endif #endif
} }
@ -83,7 +83,7 @@ void vec_sum_bbb(char *z, char *x, char *y, int len) {
} }
void vec_sc_prod_cfc(cf_t *x, float h, cf_t *z, int len) { void vec_sc_prod_cfc(cf_t *x, float h, cf_t *z, int len) {
#ifndef HAVE_VOLK #ifndef HAVE_VOLK_MULT_FUNCTION
int i; int i;
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
z[i] = x[i]*h; z[i] = x[i]*h;
@ -97,7 +97,7 @@ void vec_sc_prod_cfc(cf_t *x, float h, cf_t *z, int len) {
} }
void vec_sc_prod_ccc(cf_t *x, cf_t h, cf_t *z, int len) { void vec_sc_prod_ccc(cf_t *x, cf_t h, cf_t *z, int len) {
#ifndef HAVE_VOLK #ifndef HAVE_VOLK_MULT_FUNCTION
int i; int i;
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
z[i] = x[i]*h; z[i] = x[i]*h;
@ -162,7 +162,7 @@ void vec_fprint_i(FILE *stream, int *x, int len) {
} }
void vec_conj_cc(cf_t *x, cf_t *y, int len) { void vec_conj_cc(cf_t *x, cf_t *y, int len) {
#ifndef HAVE_VOLK #ifndef HAVE_VOLK_CONJ_FUNCTION
int i; int i;
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
y[i] = conjf(x[i]); y[i] = conjf(x[i]);
@ -173,7 +173,7 @@ void vec_conj_cc(cf_t *x, cf_t *y, int len) {
} }
void vec_prod_ccc(cf_t *x,cf_t *y, cf_t *z, int len) { void vec_prod_ccc(cf_t *x,cf_t *y, cf_t *z, int len) {
#ifndef HAVE_VOLK #ifndef HAVE_VOLK_MULT2_FUNCTION
int i; int i;
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
z[i] = x[i]*y[i]; z[i] = x[i]*y[i];
@ -201,7 +201,7 @@ float vec_avg_power_cf(cf_t *x, int len) {
} }
void vec_prod_ccc_unalign(cf_t *x,cf_t *y, cf_t *z, int len) { void vec_prod_ccc_unalign(cf_t *x,cf_t *y, cf_t *z, int len) {
#ifndef HAVE_VOLK #ifndef HAVE_VOLK_MULT_FUNCTION
int i; int i;
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
z[i] = x[i]*y[i]; z[i] = x[i]*y[i];
@ -212,7 +212,7 @@ void vec_prod_ccc_unalign(cf_t *x,cf_t *y, cf_t *z, int len) {
} }
void vec_abs_cf(cf_t *x, float *abs, int len) { void vec_abs_cf(cf_t *x, float *abs, int len) {
#ifndef HAVE_VOLK #ifndef HAVE_VOLK_MAG_FUNCTION
int i; int i;
for (i=0;i<len;i++) { for (i=0;i<len;i++) {
abs[i] = cabsf(x[i]); abs[i] = cabsf(x[i]);
@ -225,7 +225,12 @@ void vec_abs_cf(cf_t *x, float *abs, int len) {
} }
int vec_max_fi(float *x, int len) { int vec_max_fi(float *x, int len) {
#ifndef HAVE_VOLK #ifdef HAVE_VOLK_MAX_FUNCTION
unsigned int target=0;
volk_32f_index_max_16u_u(&target,x,(unsigned int) len);
return (int) target;
#else
int i; int i;
float m=-FLT_MAX; float m=-FLT_MAX;
int p=0; int p=0;
@ -236,10 +241,6 @@ int vec_max_fi(float *x, int len) {
} }
} }
return p; return p;
#else
unsigned int target=0;
volk_32f_index_max_16u_u(&target,x,(unsigned int) len);
return (int) target;
#endif #endif
} }

Loading…
Cancel
Save