Browse Source

ParseMakefileVars now recursively parses included makefiles.

tags/v0.2.15^2
Hank Anderson 10 years ago
parent
commit
cebc07cebd
2 changed files with 12 additions and 26 deletions
  1. +9
    -6
      cmake/utils.cmake
  2. +3
    -20
      kernel/CMakeLists.txt

+ 9
- 6
cmake/utils.cmake View File

@@ -13,11 +13,9 @@ function(ParseGetArchVars GETARCH_IN)
endfunction ()

# Reads a Makefile into CMake vars.
# TODO: read nested Makefiles (I think 1 level should do)
# TODO: respect IFDEF/IFNDEF?
# TODO: regex replace makefile vars, e.g. $(TSUFFIX) is set to the target arch in the var CGEMMOTCOPYOBJ = cgemm_otcopy$(TSUFFIX).$(SUFFIX)
# TODO: bail when makefile is missing, like -include
function(ParseMakefileVars MAKEFILE_IN)
macro(ParseMakefileVars MAKEFILE_IN)
message(STATUS "Reading vars from ${MAKEFILE_IN}...")
file(STRINGS ${MAKEFILE_IN} makefile_contents)
foreach (makefile_line ${makefile_contents})
@@ -25,13 +23,18 @@ function(ParseMakefileVars MAKEFILE_IN)
if (NOT "${line_match}" STREQUAL "")
set(var_name ${CMAKE_MATCH_1})
set(var_value ${CMAKE_MATCH_2})
set(${VAR_NAME} ${VAR_VALUE} PARENT_SCOPE)
set(${var_name} ${var_value})
message(STATUS "found var ${var_name} = ${var_value}")
else ()
message(STATUS "couldn't parse ${makefile_line} into a var")
string(REGEX MATCH "include \\$\\(KERNELDIR\\)/(.+)$" line_match "${makefile_line}")
if (NOT "${line_match}" STREQUAL "")
ParseMakefileVars(${KERNELDIR}/${CMAKE_MATCH_1})
else ()
message(STATUS "couldn't parse ${makefile_line} into a var")
endif ()
endif ()
endforeach ()
endfunction ()
endmacro ()

# Returns all combinations of the input list, as a list with colon-separated combinations
# E.g. input of A B C returns A B C A:B A:C B:C


+ 3
- 20
kernel/CMakeLists.txt View File

@@ -2,7 +2,7 @@
include_directories(${CMAKE_SOURCE_DIR})
include("${CMAKE_SOURCE_DIR}/cmake/kernel.cmake")

# Makeflie
# Makefile

if (DEFINED TARGET_CORE)
#override CFLAGS += -DBUILD_KERNEL -DTABLE_NAME=gotoblas_$(TARGET_CORE)
@@ -31,11 +31,7 @@ GenerateNamedObjects("${KERNELDIR}/${SCABS_KERNEL}" "COMPLEX;F_INTERFACE" "scabs
GenerateNamedObjects("${KERNELDIR}/${DCABS_KERNEL}" "DOUBLE;COMPLEX;F_INTERFACE" "dcabs1" false "" "" true)

# Makefile.L1

# TODO: need to read ${KERNELDIR}/KERNEL into CMake vars

foreach (float_type ${FLOAT_TYPES})

# a bit of metaprogramming here to pull out the appropriate KERNEL var
string(SUBSTRING ${float_type} 0 1 float_char)
GenerateNamedObjects("${KERNELDIR}/${${float_char}AMAXKERNEL}" "USE_ABS" "amax_k" false "" "" false ${float_type})
@@ -58,27 +54,14 @@ foreach (float_type ${FLOAT_TYPES})
endforeach ()

# Makefile.L2

GenerateNamedObjects("${KERNELDIR}/gemv_n.S" "DOUBLE")
GenerateNamedObjects("${KERNELDIR}/gemv_t.S" "TRANS")
GenerateCombinationObjects("generic/symv_k.c" "LOWER" "U" "" 1 "" "" 3)
GenerateNamedObjects("generic/ger.c" "" "ger_k" false "" "" "" 3)

# Makefile.L3

# TODO: these are from KERNEL.PENRYN - they should be read in from the appropriate ${KERNELDIR}/KERNEL file
set(DGEMM_BETA ../generic/gemm_beta.c)
set(DGEMMKERNEL gemm_kernel_2x4_penryn.S)
set(DGEMMINCOPY gemm_ncopy_2.S)
set(DGEMMITCOPY gemm_tcopy_2.S)
set(DGEMMONCOPY ../generic/gemm_ncopy_4.c)
set(DGEMMOTCOPY ../generic/gemm_tcopy_4.c)
set(DGEMMINCOPYOBJ gemm_incopy)
set(DGEMMITCOPYOBJ gemm_itcopy)
set(DGEMMONCOPYOBJ gemm_oncopy)
set(DGEMMOTCOPYOBJ gemm_otcopy)

GenerateNamedObjects("${KERNELDIR}/${DGEMMKERNEL}" "" "gemm_kernel" false "" "" "" 3)
message(STATUS "dgemm: ${DGEMMKERNEL}")
GenerateNamedObjects("${KERNELDIR}/${DGEMMKERNEL}" "" "gemm_kernel" false "" "" false 3)

if (DGEMMINCOPY)
GenerateNamedObjects("${KERNELDIR}/${DGEMMINCOPY}" "" "${DGEMMINCOPYOBJ}")


Loading…
Cancel
Save