I have been doing some testing on a project that I recently started building with CMake. Before moving to CMake I noticed significant improvements in build time when using the -j
option for make
with my handwritten Makefile.
Now with CMake I do the same thing and there isn't any noticeable increase in speed. Whether I run with -j
or not, I get four processes for make.exe
, though only one of them is clocking CPU time and never uses more the 25% of the CPU.
In general, The CMake generated Makefile is much slower than my handwritten Makefile. A quick test shows build times for both CMake and handwritten makefiles with and without the -j
flag:
CMake: "make -j all" = 7min
CMake: "make all" = 7min
Handwritten: "make -j all" = 2min
Handwritten: "make all" = 4min
In general, CMake is much slower and doesn't seem to utilize parallel jobs.
Can anyone explain why I'm not seeing any improvements?
(Building a Fortran program with gfortran and using CMake's auto-detect dependency feature...though I don't know if that's relevant to what I'm seeing).
Here's my CMakeLists.txt file:
## CMake Version
cmake_minimum_required(VERSION 2.8)
## Project Name
project(PROJECT)
## Use FORTRAN
enable_language(Fortran)
## Release compiler options
set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -cpp -ffree-line-length-none -fimplicit-none")
## Debug compiler options
set (CMAKE_Fortran_FLAGS_DEBUG "-g -cpp -ffree-line-length-none -fimplicit-none")
## Set directory for FORTRAN modules
set (CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/modules")
## Build Executable
add_executable(EXE
Source1.f90
Source2.f90
.
.
.
Source219.f90
Source220.f90)
And here's my original Makefile:
PROG = PROGRAM.exe
SRCS = Source1.f90 Source2.f90 ... Source219.o Source220.o
OBJS = Source1.o Source2.o ... Source219.o Source220.o
LIBS =
VPATH = src
BUILDDIR = debug
F90 = gfortran
F90FLAGS = -g -cpp -ffree-line-length-none -fimplicit-none
all: $(PROG)
$(PROG): $(OBJS)
$(F90) -o $@ $(OBJS) $(LIBS)
clean:
erase -f $(BUILDDIR)$(PROG) $(BUILDDIR)\$(OBJS) $(BUILDDIR)\*.mod
.SUFFIXES: $(SUFFIXES) .f90
.f90.o:
$(F90) $(F90FLAGS) -c $<
Source1.o: Dependency1.o Dependency2.o ... DependencyN.o
Source2.o: Dependency1.o Dependency2.o ... DependencyN.o
.
.
.
Source219.o: Dependency1.o Dependency2.o ... DependencyN.o
Source220.o: Dependency1.o Dependency2.o ... DependencyN.o
Is this on windows? If so it is because the windows version of gmake does not have a job server and recursive makefiles are not parallel. I am assuming that when you wrote make.exe that means windows. I think CVS gmake has a jobs server now. The cygwin gmake also supports the job server.
This link might help you:
http://lists.gnu.org/archive/html/make-w32/2011-07/msg00002.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With