Skip to content

Commit

Permalink
Improved the automatic dependency generation in Makefile. Now it happ…
Browse files Browse the repository at this point in the history
…ens during the compilation (in one go) and also works for C++ sources. It should be faster and produce immediate break if, e.g., header file is missing. It was tested with gcc and Intel compiler. Options for other compilers were also updated (based on corresponding manuals), but not tested.

Also updated the workarounds (linker options) in ocl/Makefile. In particular, they are all now commented out by default.
  • Loading branch information
myurkin committed Jan 26, 2013
1 parent 8d5a2a0 commit a90206a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ FFOLDER := fort
CPPFOLDER := cpp

LDLIBS := -lm
DEPFLAG := -M
DFFLAG := >
DEPFLAG := -MD
# Fortran and C++ sources generate a lot of warnings, we do not plan to investigate them
FWARN := -w

Expand Down Expand Up @@ -374,8 +373,7 @@ else ifeq ($(COMPILER),ibm)
CSTD := -qlanglvl=extc99
COPT1 := -O2
COPT2 := -O3 -qcache=auto
DFFLAG := -MF # somehow it may have problems with standard redirect (>)
DEPFLAG := -qmakedep=gcc -qsyntaxonly
DEPFLAG := -qmakedep=gcc
CWARN := -qsuppress=1506-224:1506-342:1500-036
else ifeq ($(COMPILER),hpux)
# This compiler was not tested since 2010. In particular, no C++ compiler is defined. If you
Expand All @@ -385,6 +383,7 @@ else ifeq ($(COMPILER),hpux)
CSTD := -AC99
COPT1 := +O2 +DD64
COPT2 := +O3 +DD64
DEPFLAG :+= +Md
CWARN :=
CFLAGS += -DNOT_USE_LOCK
else ifeq ($(COMPILER),other)
Expand Down
17 changes: 7 additions & 10 deletions src/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# All options are defined in Makefile and specific makefiles
# $Date:: $
#
# Copyright (C) 2010-2011 ADDA contributors
# Copyright (C) 2010-2011,2013 ADDA contributors
# This file is part of ADDA.
#
# ADDA is free software: you can redistribute it and/or modify it under the terms of the GNU
Expand All @@ -17,6 +17,7 @@
# <http://www.gnu.org/licenses/>.

# !!! This file do not have any options designed to be changed by ADDA user
# Dependencies are generated during the compilation as proposed in http://make.paulandlesley.org/autodep.html

# define objects and dependencies
COBJECTS := $(CSOURCE:.c=.o)
Expand Down Expand Up @@ -71,20 +72,16 @@ $(PROG): $(COBJECTS) $(FOBJECTS) $(CPPOBJECTS) $(LDOPTSFILE)
@echo "Building $@"
$(MYCC) -o $@ $(COBJECTS) $(FOBJECTS) $(CPPOBJECTS) $(LDFLAGS)

$(COBJECTS): %.o: %.c %.d
$(MYCC) -c $(CFLAGS) $<
$(COBJECTS): %.o: %.c $(COPTSFILE)
$(MYCC) -c $(CFLAGS) $(DEPFLAG) $<

# Dependencies are only generated for C and C++ sources; we assume that each Fortran file is completely independent or
# all of the files from dependent set are compiled at once.
$(FOBJECTS): %.o: %.f $(FOPTSFILE)
$(MYCF) -c $(FFLAGS) $<

$(CPPOBJECTS): %.o: %.cpp $(CPPOPTSFILE)
$(MYCCPP) -c $(CPPFLAGS) $<

# Dependencies are only generated for C sources; we assume that each Fortran or C++ file is
# completely independent or all of the files from dependent set are compiled at once.
$(CDEPEND): %.d: %.c $(COPTSFILE)
if ($(MYCC) $(DEPFLAG) $(CFLAGS) $< $(DFFLAG) $@.$$$$); then \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; rm -f $@.$$$$; else false; fi
$(MYCCPP) -c $(CPPFLAGS) $(DEPFLAG) $<

# Special rule for generation of stringified CL source. Used only for ocl. All relevant variables
# are defined in ocl/Makefile
Expand Down
14 changes: 8 additions & 6 deletions src/ocl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
#CFLAGS += -I"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v3.2/include"
#LDFLAGS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v3.2/lib/Win32"

# This workaround is to disable linker warnings when linking against 32-bit OpenCL.dll on 64-bit Windows. The issue
# appeared with Nvidia library supplied with driver 301.42. Uncomment the following 3 lines to enable it.
#ifneq ($(filter -m32,$(LDFLAGS)),)
# LDFLAGS += -Wl,--enable-stdcall-fixup
#endif

ifneq ($(filter CLFFT_APPLE,$(OPTIONS)),)
ifeq ($(filter NO_CPP,$(OPTIONS)),)
CPPSOURCE += fft_execute.cpp fft_setup.cpp fft_kernelstring.cpp
Expand All @@ -47,6 +53,8 @@ else # AMD clFFT flags
# Uncomment the following line if you experience problems during linking, like
# "...libclAmdFft.Runtime.so: undefined reference to `clRetainContext@OPENCL_1.0'"
# This is caused by Nvidia OpenCL libraries on Linux (hopefully it will disappear in next releases of this library)
# The drawback of this workaround is that a warning would appear at each execution of adda_ocl. If you don't like it,
# provide another libOpenCL.so (e.g. that from AMD) for linkig.
#LDFLAGS +=-Wl,--unresolved-symbols=ignore-in-shared-libs
endif

Expand All @@ -68,12 +76,6 @@ else
CLSOURCE := oclkernels.cl
endif

# This fix is to disable linker warnings when linking against 32-bit OpenCL.dll on 64-bit Windows.
# The issue appeared with Nvidia library supplied with driver 301.42
ifneq ($(filter -m32,$(LDFLAGS)),)
LDFLAGS += -Wl,--enable-stdcall-fixup
endif

# This is a weird prefix, which is required since that is how .clstr files are quoted in .d files
CLSPREFIX := ../$(OCL)/
CLSTRING := $(CLSOURCE:.cl=.clstr)
Expand Down

0 comments on commit a90206a

Please sign in to comment.