diff --git a/Makefile b/Makefile index e066ea36a..1f86acc7e 100644 --- a/Makefile +++ b/Makefile @@ -213,6 +213,20 @@ MK_REFKERN_OBJS := $(foreach arch, $(CONFIG_LIST), \ # Generate object file paths for all of the portable framework source code. MK_FRAME_OBJS := $(call gen-obj-paths-from-src,$(FRAME_SRC_SUFS),$(MK_FRAME_SRC),$(FRAME_PATH),$(BASE_OBJ_FRAME_PATH)) +# Generate object file paths for the addon source code. If one or more addons +# were not enabled a configure-time, these variable will we empty. +# NOTE: We separate the source and objects into kernel and non-kernel lists. +MK_ADDON_KERS_SRC := $(foreach addon, $(ADDON_LIST), \ + $(filter $(ADDON_PATH)/$(addon)/$(KERNELS_DIR)/%, \ + $(MK_ADDON_SRC)) \ + ) +MK_ADDON_OTHER_SRC := $(foreach addon, $(ADDON_LIST), \ + $(filter-out $(ADDON_PATH)/$(addon)/$(KERNELS_DIR)/%, \ + $(MK_ADDON_SRC)) \ + ) +MK_ADDON_KERS_OBJS := $(call gen-obj-paths-from-src,$(ADDON_SRC_SUFS),$(MK_ADDON_KERS_SRC),$(ADDON_PATH),$(BASE_OBJ_ADDON_PATH)) +MK_ADDON_OTHER_OBJS := $(call gen-obj-paths-from-src,$(ADDON_SRC_SUFS),$(MK_ADDON_OTHER_SRC),$(ADDON_PATH),$(BASE_OBJ_ADDON_PATH)) +MK_ADDON_OBJS := $(MK_ADDON_KERS_OBJS) $(MK_ADDON_OTHER_OBJS) # AMD has optimized some of the framework files, these optimizations # may not be compatible with other platforms. # @@ -237,11 +251,6 @@ endif # Generate object file paths for all of the debgu and trace logger. MK_AOCLDTL_OBJS := $(call gen-obj-paths-from-src,$(AOCLDTL_SRC_SUFS),$(MK_AOCLDTL_SRC),$(AOCLDTL_PATH),$(BASE_OBJ_AOCLDTL_PATH)) - -# Generate object file paths for the addon source code. If one or more addons -# were not enabled a configure-time, this variable will we empty. -MK_ADDON_OBJS := $(call gen-obj-paths-from-src,$(ADDON_SRC_SUFS),$(MK_ADDON_SRC),$(ADDON_PATH),$(BASE_OBJ_ADDON_PATH)) - # Generate object file paths for the sandbox source code. If a sandbox was not # enabled a configure-time, this variable will we empty. MK_SANDBOX_OBJS := $(call gen-obj-paths-from-src,$(SANDBOX_SRC_SUFS),$(MK_SANDBOX_SRC),$(SANDBOX_PATH),$(BASE_OBJ_SANDBOX_PATH)) @@ -595,18 +604,34 @@ endef # first argument: a configuration name from the union of config_list and # config_name, used to look up the CFLAGS to use during compilation. +# second argument: the C99 addon file suffix being considered. define make-c99-addon-rule $(BASE_OBJ_ADDON_PATH)/%.o: $(ADDON_PATH)/%.$(2) $(BLIS_H_FLAT) $(ADDON_H99_FILES) $(MAKE_DEFS_MK_PATHS) ifeq ($(ENABLE_VERBOSE),yes) - $$(if $$(findstring _amd512vnni,$$<),$$(eval LPGEMM_MARCH_VAR=icelake-server -mavx512bf16),$$(eval LPGEMM_MARCH_VAR=znver3)) - $(CC) -march=$$(LPGEMM_MARCH_VAR) $(call get-addon-c99flags-for,$(1)) -c $$< -o $$@ + $(CC) $(call get-addon-c99flags-for,$(1)) -c $$< -o $$@ else @echo "Compiling $$@" $(call get-addon-c99text-for,$(1)) - $$(if $$(findstring _amd512vnni,$$<),$$(eval LPGEMM_MARCH_VAR=icelake-server -mavx512bf16),$$(eval LPGEMM_MARCH_VAR=znver3)) - @$(CC) -march=$$(LPGEMM_MARCH_VAR) $(call get-addon-c99flags-for,$(1)) -c $$< -o $$@ + @$(CC) $(call get-addon-c99flags-for,$(1)) -c $$< -o $$@ endif endef +# first argument: a configuration name from the union of config_list and +# config_name, used to look up the CFLAGS to use during compilation. +# second argument: the C99 addon file suffix being considered. +# third argument: the name of the addon being considered. +define make-c99-addon-kers-rule +$(BASE_OBJ_ADDON_PATH)/$(3)/$(KERNELS_DIR)/%.o: $(ADDON_PATH)/$(3)/$(KERNELS_DIR)/%.$(2) $(BLIS_H_FLAT) $(ADDON_H99_FILES) $(MAKE_DEFS_MK_PATHS) +ifeq ($(ENABLE_VERBOSE),yes) + $(CC) $(call get-addon-kernel-c99flags-for,$(1)) -c $$< -o $$@ +else + @echo "Compiling $$@" $(call get-addon-kernel-text-for,$(1)) + @$(CC) $(call get-addon-kernel-c99flags-for,$(1)) -c $$< -o $$@ +endif +endef + +# first argument: a configuration name from the union of config_list and +# config_name, used to look up the CFLAGS to use during compilation. +# second argument: the C++ addon file suffix being considered. define make-cxx-addon-rule $(BASE_OBJ_ADDON_PATH)/%.o: $(ADDON_PATH)/%.$(2) $(BLIS_H_FLAT) $(ADDON_HXX_FILES) $(MAKE_DEFS_MK_PATHS) ifeq ($(ENABLE_VERBOSE),yes) @@ -619,6 +644,7 @@ endef # first argument: a configuration name from the union of config_list and # config_name, used to look up the CFLAGS to use during compilation. +# second argument: the C99 sandbox file suffix being considered. define make-c99-sandbox-rule $(BASE_OBJ_SANDBOX_PATH)/%.o: $(SANDBOX_PATH)/%.$(2) $(BLIS_H_FLAT) $(SANDBOX_H99_FILES) $(MAKE_DEFS_MK_PATHS) ifeq ($(ENABLE_VERBOSE),yes) @@ -629,6 +655,9 @@ else endif endef +# first argument: a configuration name from the union of config_list and +# config_name, used to look up the CFLAGS to use during compilation. +# second argument: the C++ sandbox file suffix being considered. define make-cxx-sandbox-rule $(BASE_OBJ_SANDBOX_PATH)/%.o: $(SANDBOX_PATH)/%.$(2) $(BLIS_H_FLAT) $(SANDBOX_HXX_FILES) $(MAKE_DEFS_MK_PATHS) ifeq ($(ENABLE_VERBOSE),yes) @@ -682,6 +711,12 @@ $(foreach kset, $(KERNEL_LIST), $(eval $(call make-kernels-rule,$(kset),$(call g $(foreach suf, $(ADDON_C99_SUFS), \ $(foreach conf, $(CONFIG_NAME), $(eval $(call make-c99-addon-rule,$(conf),$(suf))))) +# Instantiate the build rule for C addon/kernels files. Use the CFLAGS for the +# configuration family. +$(foreach addon, $(ADDON_LIST), \ +$(foreach suf, $(ADDON_C99_SUFS), \ +$(foreach conf, $(CONFIG_NAME), $(eval $(call make-c99-addon-kers-rule,$(conf),$(suf),$(addon)))))) + # Instantiate the build rule for C++ addon files. Use the CFLAGS for the # configuration family. $(foreach suf, $(ADDON_CXX_SUFS), \ diff --git a/common.mk b/common.mk index 0fdf659a9..5912f53b4 100644 --- a/common.mk +++ b/common.mk @@ -159,7 +159,7 @@ get-kernel-cflags-for = $(strip $(call load-var-for,CKOPTFLAGS,$(1)) \ $(BUILD_SYMFLAGS) \ ) -# When compiling sandboxes, we use flags similar to those of general framework +# When compiling addons, we use flags similar to those of general framework # source. This ensures that the same code can be linked and run across various # sub-configurations. get-addon-c99flags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \ @@ -174,6 +174,15 @@ get-addon-cxxflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \ $(BUILD_CPPFLAGS) \ $(BUILD_SYMFLAGS) \ ) +# When compiling addon kernels, we use flags similar to those of kernels +# flags, except we also include the addon header paths. +get-addon-kernel-c99flags-for = $(strip $(call load-var-for,CKOPTFLAGS,$(1)) \ + $(call load-var-for,CKVECFLAGS,$(1)) \ + $(call get-noopt-cflags-for,$(1)) \ + $(CADDONINCFLAGS) \ + $(BUILD_CPPFLAGS) \ + $(BUILD_SYMFLAGS) \ + ) # When compiling sandboxes, we use flags similar to those of general framework # source. This ensures that the same code can be linked and run across various @@ -208,17 +217,17 @@ get-user-cflags-for = $(strip $(call load-var-for,COPTFLAGS,$(1)) \ # Define functions that return messages appropriate for each non-verbose line # of compilation output. -get-noopt-text = "(CFLAGS for no optimization)" -get-refinit-text-for = "('$(1)' CFLAGS for ref. kernel init)" -get-refkern-text-for = "('$(1)' CFLAGS for ref. kernels)" -get-config-text-for = "('$(1)' CFLAGS for config code)" -get-frame-text-for = "('$(1)' CFLAGS for framework code)" -get-aocldtl-text-for = "('$(1)' CFLAGS for AOCL debug and trace code)" -get-kernel-text-for = "('$(1)' CFLAGS for kernels)" -get-addon-c99text-for = "('$(1)' CFLAGS for addons)" -get-addon-cxxtext-for = "('$(1)' CXXFLAGS for addons)" -get-sandbox-c99text-for = "('$(1)' CFLAGS for sandboxes)" -get-sandbox-cxxtext-for = "('$(1)' CXXFLAGS for sandboxes)" +get-noopt-text = "(CFLAGS for no optimization)" +get-refinit-text-for = "('$(1)' CFLAGS for ref. kernel init)" +get-refkern-text-for = "('$(1)' CFLAGS for ref. kernels)" +get-config-text-for = "('$(1)' CFLAGS for config code)" +get-frame-text-for = "('$(1)' CFLAGS for framework code)" +get-kernel-text-for = "('$(1)' CFLAGS for kernels)" +get-addon-c99text-for = "('$(1)' CFLAGS for addons)" +get-addon-cxxtext-for = "('$(1)' CXXFLAGS for addons)" +get-addon-kernel-text-for = "('$(1)' CFLAGS for addon kernels)" +get-sandbox-c99text-for = "('$(1)' CFLAGS for sandboxes)" +get-sandbox-cxxtext-for = "('$(1)' CXXFLAGS for sandboxes)"