Files
blis/testsuite/Makefile
Field G. Van Zee 453deb2906 Implemented runtime kernel management.
Details:
- Reworked the build system around a configuration registry file, named
  config_registry', that identifies valid configuration targets, their
  constituent sub-configurations, and the kernel sets that are needed by
  those sub-configurations. The build system now facilitates the building
  of a single library that can contains kernels and cache/register
  blocksizes for multiple configurations (microarchitectures). Reference
  kernels are also built on a per-configuration basis.
- Updated the Makefile to use new variables set by configure via the
  config.mk.in template, such as CONFIG_LIST, KERNEL_LIST, and KCONFIG_MAP,
  in determining which sub-configurations (CONFIG_LIST) and kernel sets
  (KERNEL_LIST) are included in the library, and which make_defs.mk files'
  CFLAGS (KCONFIG_MAP) are used when compiling kernels.
- Reorganized 'kernels' directory into a "flat" structure. Renamed kernel
  functions into a standard format that includes the kernel set name
  (e.g. 'haswell'). Created a "bli_kernels_<kernelset>.h" file in each
  kernels sub-directory. These files exist to provide prototypes for the
  kernels present in those directories.
- Reorganized reference kernels into a top-level 'ref_kernels' directory.
  This directory includes a new source file, bli_cntx_ref.c (compiled on
  a per-configuration basis), that defines the code needed to initialize
  a reference context and a context for induced methods for the
  microarchitecture in question.
- Rewrote make_defs.mk files in each configuration so that the compiler
  variables (e.g. CFLAGS) are "stored" (renamed) on a per-configuration
  basis.
- Modified bli_config.h.in template so that bli_config.h is generated with
  #defines for the config (family) name, the sub-configurations that are
  associated with the family, and the kernel sets needed by those
  sub-configurations.
- Deprecated all kernel-related information in bli_kernel.h and transferred
  what remains to new header files named "bli_arch_<configname>.h", which
  are conditionally #included from a new header bli_arch.h. These files
  are still needed to set library-wide parameters such as custom
  malloc()/free() functions or SIMD alignment values.
- Added bli_cntx_init_<configname>.c files to each configuration directory.
  The files contain a function, named the same as the file, that initializes
  a "native" context for a particular configuration (microarchitecture). The
  idea is that optimized kernels, if available, will be initialized into
  these contexts. Other fields will retain pointers to reference functions,
  which will be compiled on a per-configuration basis. These bli_cntx_init_*()
  functions will be called during the initialization of the global kernel
  structure. They are thought of as initializing for "native" execution, but
  they also form the basis for contexts that use induced methods. These
  functions are prototyped, along with their _ref() and _ind() brethren, by
  prototype-generating macros in bli_arch.h.
- Added a new typedef enum in bli_type_defs.h to define an arch_t, which
  identifies the various sub-configurations.
- Redesigned the global kernel structure (gks) around a 2D array of cntx_t
  structures (pointers to cntx_t, actually). The first dimension is indexed
  over arch_t and the inner dimension is the ind_t (induced method) for
  each microarchitecture. When a microarchitecture (configuration) is
  "registered" at init-time, the inner array for that configuration in the
  2D array is initialized (and allocated, if it hasn't been already). The
  cntx_t slot for BLIS_NAT is initialized immediately and those for other
  induced method types are initialized and cached on-demand, as needed. At
  cntx_t registration, we also store function pointers to cntx_init functions
  that will initialize (a) "reference" contexts and (b) contexts for use with
  induced methods. We don't cache the full contexts for reference contexts
  since they are rarely needed. The functions that initialize these two kinds
  of contexts are generated automatically for each targeted sub-configuration
  from cpp-templatized code at compile-time. Induced method contexts that
  need "stage" adjustments can still obtain them via functions in
  bli_cntx_ind_stage.c.
- Added new functions and functionality to bli_cntx.c, such as for setting
  the level-1f, level-1v, and packm kernels, and for converting a native
  context into one for executing an induced method.
- Moved the checking of register/cache blocksize consistency from being cpp
  macros in bli_kernel_macro_defs.h to being runtime checks defined in
  bli_check.c and called from bli_gks_register_cntx() at the time that the
  global kernel structure's internal context is initialized for a given
  microarchitecture/configuration.
- Deprecated all of the old per-operation bli_*_cntx.c files and removed
  the previous operation-level cntx_t_init()/_finalize() invocations.
  Instead, we now query the gks for a suitable context, usually via
  bli_gks_query_cntx().
- Deprecated support for the 3m2 and 3m3 induced methods. (They required
  hackery that I was no longer willing to support.)
- Consolidated the 1e and 1r packm kernels for any given register blocksize
  into a single kernel that will branch on the schema and support packing
  to both formats.
- Added the cntx_t* argument to all packm kernel signatures.
- Deprecated the local function pointer array in all bli_packm_cxk*.c files
  and instead obtain the packm kernel from the cntx_t.
- Added bli_calloc_intl(), which serves as the calloc-equivalent to to
  bli_malloc_intl(). Useful when we wish to allocate and initialize to
  zero/NULL.
- Converted existing cpp macro functions defined in bli_blksz.h, bli_func.h,
  bli_cntx.h into static functions.
2017-10-18 13:29:32 -05:00

392 lines
12 KiB
Makefile

#
#
# BLIS
# An object-based framework for developing high-performance BLAS-like
# libraries.
#
# Copyright (C) 2014, The University of Texas at Austin
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# - Neither the name of The University of Texas at Austin nor the names
# of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
#
# Makefile
#
# Field G. Van Zee
#
# Makefile for standalone BLIS test drivers.
#
#
# --- Makefile PHONY target definitions ----------------------------------------
#
.PHONY: all bin clean \
check-env check-env-mk check-env-fragments check-env-make-defs \
run run-amd64 run-x86 run-arm
#
# --- Makefile initialization --------------------------------------------------
#
# Set the relative location to the top-level distribution path $(DIST_PATH).
RELPATH := ..
# Define the name of the common makefile fragment.
COMMON_MK_FILE := common.mk
# All makefile fragments in the tree will have this name.
FRAGMENT_MK := .fragment.mk
# Important locations and directory names.
CONFIG_DIR := config
FRAME_DIR := frame
REFKERN_DIR := ref_kernels
KERNELS_DIR := kernels
LIB_DIR := lib
#
# --- Include common makefile --------------------------------------------------
#
# Construct the path to the makefile configuration file that was generated by
# the configure script.
COMMON_MK_PATH := ../$(COMMON_MK_FILE)
# Include the common makefile fragment.
-include $(COMMON_MK_PATH)
# Detect whether we actually got the common makefile fragment. If we didn't,
# then it is likely that the user has not yet generated it (via configure).
ifeq ($(strip $(COMMON_MK_INCLUDED)),yes)
COMMON_MK_PRESENT := yes
else
COMMON_MK_PRESENT := no
endif
# Override the DIST_PATH value obtained from config.mk, since it is relative
# to the build directory.
DIST_PATH := ..
# Construct paths to the three primary directories of source code:
# general framework code, reference kernel code, and optimized kernel
# code.
CONFIG_PATH := $(DIST_PATH)/$(CONFIG_DIR)
FRAME_PATH := $(DIST_PATH)/$(FRAME_DIR)
REFKERN_PATH := $(DIST_PATH)/$(REFKERN_DIR)
KERNELS_PATH := $(DIST_PATH)/$(KERNELS_DIR)
#
# --- Include makefile fragments -----------------------------------------------
#
# Initialize our list of directory paths to makefile fragments with the empty
# list. This variable will accumulate all of the directory paths in which
# makefile fragments reside.
FRAGMENT_DIR_PATHS :=
# Construct paths to each of the sub-configurations specified in the
# configuration list.
CONFIG_PATHS := $(addprefix $(CONFIG_PATH)/, $(CONFIG_LIST))
# This variable is used by the include statements as they recursively include
# one another. For the 'config' directory, we initialize it to that directory
# in preparation to include the fragments in the configuration sub-directory.
PARENT_PATH := $(DIST_PATH)/$(CONFIG_DIR)
# Recursively include the makefile fragments in each of the sub-configuration
# directories.
-include $(addsuffix /$(FRAGMENT_MK), $(CONFIG_PATHS))
# Construct paths to each of the kernel sets required by the sub-configurations
# in the configuration list.
KERNEL_PATHS := $(addprefix $(KERNELS_PATH)/, $(KERNEL_LIST))
# This variable is used by the include statements as they recursively include
# one another. For the 'kernels' directory, we initialize it to that directory
# in preparation to include the fragments in the configuration sub-directory.
PARENT_PATH := $(DIST_PATH)/$(KERNELS_DIR)
# Recursively include the makefile fragments in each of the kernels sub-
# directories.
-include $(addsuffix /$(FRAGMENT_MK), $(KERNEL_PATHS))
# This variable is used by the include statements as they recursively include
# one another. For the framework and reference kernel source trees (ie: the
# 'frame' and 'ref_kernels' directories), we initialize it to the top-level
# directory since that is its parent. Same for the kernels directory, since it
# resides in the same top-level directory.
PARENT_PATH := $(DIST_PATH)
# Recursively include all the makefile fragments in the directories for the
# reference kernels and portable framework.
-include $(addsuffix /$(FRAGMENT_MK), $(REFKERN_PATH))
-include $(addsuffix /$(FRAGMENT_MK), $(FRAME_PATH))
# Create a list of the makefile fragments.
MAKEFILE_FRAGMENTS := $(addsuffix /$(FRAGMENT_MK), $(FRAGMENT_DIR_PATHS))
# Detect whether we actually got any makefile fragments. If we didn't, then it
# is likely that the user has not yet generated them (via configure).
ifeq ($(strip $(MAKEFILE_FRAGMENTS)),)
MAKEFILE_FRAGMENTS_PRESENT := no
else
MAKEFILE_FRAGMENTS_PRESENT := yes
endif
#
# --- Compiler include path definitions ----------------------------------------
#
# Expand the fragment paths that contain .h files to attain the set of header
# files present in all fragment paths.
MK_HEADER_FILES := $(foreach frag_path, .. $(FRAGMENT_DIR_PATHS), \
$(wildcard $(frag_path)/*.h))
# Strip the leading, internal, and trailing whitespace from our list of header
# files. This makes the "make install-headers" much more readable.
MK_HEADER_FILES := $(strip $(MK_HEADER_FILES))
# Expand the fragment paths that contain .h files, and take the first
# expansion. Then, strip the header filename to leave the path to each header
# location. Notice this process even weeds out duplicates! Add the config
# directory manually since it contains FLA_config.h.
MK_HEADER_DIR_PATHS := $(dir $(foreach frag_path, .. $(FRAGMENT_DIR_PATHS), \
$(firstword $(wildcard $(frag_path)/*.h))))
# Add -I to each header path so we can specify our include search paths to the
# C compiler.
INCLUDE_PATHS := $(strip $(patsubst %, -I%, $(MK_HEADER_DIR_PATHS)))
CFLAGS := $(CFLAGS) $(INCLUDE_PATHS)
#
# --- BLAS and LAPACK implementations ------------------------------------------
#
# BLIS library and header path. This is simply wherever it was installed.
#BLIS_LIB_PATH := $(INSTALL_PREFIX)/lib
#BLIS_INC_PATH := $(INSTALL_PREFIX)/include/blis
# BLIS library.
BLIS_LIB_PATH := $(DIST_PATH)/$(LIB_DIR)/$(CONFIG_NAME)
BLIS_LIB := $(BLIS_LIB_PATH)/libblis.a
# BLAS library path(s). This is where the BLAS libraries reside.
#BLAS_LIB_PATH := $(HOME)/flame/lib
# OpenBLAS, ATLAS, and MKL libraries.
#BLAS_LIB := $(LIB_PATH)/libblas.a
#BLAS_LIB := $(LIB_PATH)/libgoto.a
#BLAS_LIB := $(LIB_PATH)/libgoto2.a
#OPENBLAS_LIB := $(BLAS_LIB_PATH)/libopenblas.a
#ATLAS_LIB := $(BLAS_LIB_PATH)/libf77blas.a \
# $(BLAS_LIB_PATH)/libatlas.a
#MKL_LIB := -L/opt/intel/mkl/10.2.2.025/lib/em64t/ \
# -lmkl_sequential -lmkl_core -lmkl_intel_lp64
#
# --- Optional overrides -------------------------------------------------------
#
# Uncomment and modify these definitions if you wish to override the values
# present in the current BLIS configuration's makefile definitions file
# (ie: config/<configname>/make_defs.mk).
# CC := gcc
# LINKER := $(CC)
# CFLAGS := -g -O2 -Wall -Wno-comment
# LDFLAGS :=
# INSTALL_PREFIX := $(HOME)/blis
#
# --- General build definitions ------------------------------------------------
#
TEST_SRC_PATH := src
TEST_OBJ_PATH := obj
# Gather all local object files.
TEST_OBJS := $(sort $(patsubst $(TEST_SRC_PATH)/%.c, \
$(TEST_OBJ_PATH)/%.o, \
$(wildcard $(TEST_SRC_PATH)/*.c)))
ifeq ($(CONFIG_NAME),pnacl)
# Linked executable
TEST_BIN := test_libblis.unstable.pexe
# Finalized executable
TEST_BIN_PNACL := test_libblis.pexe
# Translated executable for x86-64
TEST_BIN_AMD64 := test_libblis.x86-64.nexe
# Translated executable for x86
TEST_BIN_X86 := test_libblis.x86.nexe
# Translated executable for ARM
TEST_BIN_ARM := test_libblis.arm.nexe
else
# Binary executable name.
TEST_BIN := test_libblis.x
endif
# Add installed and local header paths to CFLAGS
CFLAGS += -I$(BLIS_INC_PATH) -I$(TEST_SRC_PATH)
#
# --- Targets/rules ------------------------------------------------------------
#
# --- Primary targets ---
all: check-env bin
ifeq ($(CONFIG_NAME),pnacl)
bin: check-env $(TEST_BIN) $(TEST_BIN_PNACL) $(TEST_BIN_AMD64) $(TEST_BIN_X86) $(TEST_BIN_ARM)
else
bin: check-env $(TEST_BIN)
endif
# --- Environment check rules ---
check-env: check-env-make-defs check-env-fragments check-env-mk
check-env-mk:
ifeq ($(CONFIG_MK_PRESENT),no)
$(error Cannot proceed: config.mk not detected! Run configure first)
endif
check-env-fragments: check-env-mk
ifeq ($(MAKEFILE_FRAGMENTS_PRESENT),no)
$(error Cannot proceed: makefile fragments not detected! Run configure first)
endif
check-env-make-defs: check-env-fragments
ifeq ($(MAKE_DEFS_MK_PRESENT),no)
$(error Cannot proceed: make_defs.mk not detected! Invalid configuration)
endif
# --Object file rules --
$(TEST_OBJ_PATH)/%.o: $(TEST_SRC_PATH)/%.c $(BLIS_LIB)
ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
$(CC) $(CFLAGS) -c $< -o $@
else
@echo "Compiling $<"
@$(CC) $(CFLAGS) -c $< -o $@
endif
# -- Executable file rules --
$(TEST_BIN): $(TEST_OBJS) $(BLIS_LIB)
ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
$(LINKER) $(TEST_OBJS) $(BLIS_LIB) $(LDFLAGS) -o $@
else
@echo "Linking $@ against '$(BLIS_LIB) $(LDFLAGS)'"
@$(LINKER) $(TEST_OBJS) $(BLIS_LIB) $(LDFLAGS) -o $@
endif
ifeq ($(CONFIG_NAME),pnacl)
# Finalize PNaCl executable (i.e. convert from LLVM bitcode to PNaCl bitcode)
$(TEST_BIN_PNACL): $(TEST_BIN)
ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
$(FINALIZER) $(FINFLAGS) -o $@ $(TEST_BIN)
else
@echo "Finalizing $@"
@$(FINALIZER) $(FINFLAGS) -o $@ $(TEST_BIN)
endif
# Translate PNaCl executable to x86-64 NaCl executable
$(TEST_BIN_AMD64): $(TEST_BIN_PNACL)
ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
$(TRANSLATOR) $(TRNSFLAGS) $(TRNSAMD64FLAGS) $< -o $@
else
@echo "Translating $< -> $@"
@$(TRANSLATOR) $(TRNSFLAGS) $(TRNSAMD64FLAGS) $< -o $@
endif
# Translate PNaCl executable to x86 NaCl executable
$(TEST_BIN_X86): $(TEST_BIN_PNACL)
ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
$(TRANSLATOR) $(TRNSFLAGS) $(TRNSX86FLAGS) $< -o $@
else
@echo "Translating $< -> $@"
@$(TRANSLATOR) $(TRNSFLAGS) $(TRNSX86FLAGS) $< -o $@
endif
# Translate PNaCl executable to ARMv7 NaCl executable
$(TEST_BIN_ARM): $(TEST_BIN_PNACL)
ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
$(TRANSLATOR) $(TRNSFLAGS) $(TRNSARMFLAGS) $< -o $@
else
@echo "Translating $< -> $@"
@$(TRANSLATOR) $(TRNSFLAGS) $(TRNSARMFLAGS) $< -o $@
endif
endif
# -- Test run rules --
ifeq ($(CONFIG_NAME),pnacl)
run-amd64: $(TEST_BIN_AMD64)
$(NACL_SDK_ROOT)/tools/sel_ldr_x86_64 -a -c -q -B $(NACL_SDK_ROOT)/tools/irt_core_x86_64.nexe -- $(TEST_BIN_AMD64)
run-x86: $(TEST_BIN_X86)
$(NACL_SDK_ROOT)/tools/sel_ldr_x86_32 -a -c -q -B $(NACL_SDK_ROOT)/tools/irt_core_x86_32.nexe -- $(TEST_BIN_X86)
run-arm: $(TEST_BIN_ARM)
$(NACL_SDK_ROOT)/tools/sel_ldr_arm -a -c -q -B $(NACL_SDK_ROOT)/tools/irt_core_arm.nexe -- $(TEST_BIN_ARM)
else
run: $(TEST_BIN)
./$(TEST_BIN)
endif
# -- Clean rules --
ifeq ($(CONFIG_NAME),pnacl)
clean:
- $(RM_F) $(TEST_OBJS) $(TEST_BIN) $(TEST_BIN_PNACL) $(TEST_BIN_AMD64) $(TEST_BIN_X86) $(TEST_BIN_ARM)
else
clean:
- $(RM_F) $(TEST_OBJS) $(TEST_BIN)
endif