- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am using MKL (the student version) with MPICH2.In my Makefile, the paths for MKL are hardcoded. How can I make it that they get more general? I mean, that now that my professor will check the project, assuming he was MKL installed in his system, how can he compile it? I would like to provide a Makefile that would be (almost) ready to run.
OBJSDIR = obj OBJS = $(OBJSDIR)/main.o $(OBJSDIR)/IO.o $(OBJSDIR)/alloc.o $(OBJSDIR)/communication.o $(OBJSDIR)/accuracy.o SOURCE = main.cpp src/IO.cpp src/alloc.cpp src/communication.cpp src/accuracy.cpp HEADER = headers/IO.h headers/alloc.h headers/communication.h headers/accuracy.h OUT = test CXX = ../../mpich-install/bin/mpic++ CXXFLAGS = -I../../intel/mkl/include -Wl,--start-group -Wl,--end-group -lpthread -lm -ldl -Wall LDFLAGS = ../../intel/mkl/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group ../../intel/mkl/lib/intel64/libmkl_intel_lp64.a ../../intel/mkl/lib/intel64/libmkl_core.a ../../intel/mkl/lib/intel64/libmkl_sequential.a -Wl,--end-group ../../intel/mkl/lib/intel64/libmkl_blacs_intelmpi_lp64.a -lpthread -lm -ldl all: $(OBJSDIR) $(OUT) $(OBJSDIR): mkdir $(OBJSDIR) $(OUT): $(OBJS) $(CXX) $(OBJS) -o $(OUT) $(CXXFLAGS) $(LDFLAGS) # make -f Makefile clean # create/compile the individual files >>separately<< $(OBJSDIR)/main.o: main.cpp $(CXX) -c main.cpp $(CXXFLAGS) -o $@ $(OBJSDIR)/IO.o: src/IO.cpp $(CXX) -c src/IO.cpp $(CXXFLAGS) -o $@ $(OBJSDIR)/alloc.o: src/alloc.cpp $(CXX) -c src/alloc.cpp $(CXXFLAGS) -o $@ $(OBJSDIR)/communication.o: src/communication.cpp $(CXX) -c src/communication.cpp $(CXXFLAGS) -o $@ $(OBJSDIR)/accuracy.o: src/accuracy.cpp $(CXX) -c src/accuracy.cpp $(CXXFLAGS) -o $@ .PHONY: clean clean: rm -rf $(OBJSDIR)/*.o
So, how to modify CXXFLAGS and LDFLAGS? The linker advisor didn't help much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sourcing mklvars.sh/csh or compilervars.sh/csh sets MKLROOT environment variable pointing to the MKL installation directory. Therefore you can use $(MKLROOT) in your Makefile. For example:
CXXFLAGS = -I$(MKLROOT)/include LDFLAGS = $(MKLROOT)/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_sequential.a -Wl,--end-group $(MKLROOT)/lib/intel64/libmkl_blacs_intelmpi_lp64.a -lpthread -lm -ldl
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sourcing mklvars.sh/csh or compilervars.sh/csh sets MKLROOT environment variable pointing to the MKL installation directory. Therefore you can use $(MKLROOT) in your Makefile. For example:
CXXFLAGS = -I$(MKLROOT)/include LDFLAGS = $(MKLROOT)/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_sequential.a -Wl,--end-group $(MKLROOT)/lib/intel64/libmkl_blacs_intelmpi_lp64.a -lpthread -lm -ldl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Roman,
this didn't work, since I am getting errors of this nature: g++: error: /lib/intel64/libmkl_scalapack_lp64.a: No such file or directory
How to fix it?
George
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MKLROOT is set by sourcing the mklvars script in the MKL installation. Of course, it requires such an installation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's it Tim, nice. I am going to accept Roman's answer, but I would like Roman to edit his post with the information of Tim.
Thanks,
George

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page