Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.80 KB | None | 0 0
  1. # Paths where MAGMA, CUDA, and OpenBLAS are installed
  2. MAGMADIR     ?= /opt/magma
  3. CUDADIR      ?= /opt/cuda
  4. OPENBLASDIR  ?= /usr/local/openblas
  5.  
  6. CC            = gcc
  7. FORT          = gfortran
  8. LD            = gcc
  9. CFLAGS        = -Wall
  10. LDFLAGS       = -Wall
  11.  
  12. MAGMA_CFLAGS   := -DADD_ -I$(MAGMADIR)/include -I$(CUDADIR)/include
  13. MAGMA_F90FLAGS := -I$(MAGMADIR)/include -Dmagma_devptr_t="integer(kind=8)"
  14.  
  15. MAGMA_LIBS   := -L$(MAGMADIR)/lib -L$(CUDADIR)/lib64 -L$(OPENBLASDIR)/lib \
  16.                 -llapack -lmagma -lcublas -lcudart -lopenblas
  17.  
  18. # Alternatively, using pkg-config (see README.txt):
  19. #MAGMA_CFLAGS := $(shell pkg-config --cflags magma)
  20. #MAGMA_LIBS   := $(shell pkg-config --libs   magma)
  21.  
  22.  
  23. # ----------------------------------------
  24. default:
  25.     @echo "Available make targets are:"
  26.     @echo "  make all       # compiles both example_v1, example_v2, and example_f"
  27.     @echo "  make c         # compiles example_v1 and example_v2"
  28.     @echo "  make fortran   # compiles example_f"
  29.     @echo "  make clean     # deletes executables and object files"
  30.  
  31. all: c fortran
  32.  
  33. c: example_v1 example_v2
  34.  
  35. fortran: example_f
  36.  
  37. clean:
  38.     -rm -f example_v1 example_v2 example_f *.o *.mod
  39.  
  40. .SUFFIXES:
  41.  
  42.  
  43. # ----------------------------------------
  44. # C example
  45. %.o: %.c
  46.     $(CC) $(CFLAGS) $(MAGMA_CFLAGS) -c -o $@ $<
  47.  
  48. example_v1: example_v1.o
  49.     $(LD) $(LDFLAGS) -o $@ $^ $(MAGMA_LIBS)
  50.  
  51. example_v2: example_v2.o
  52.     $(LD) $(LDFLAGS) -o $@ $^ $(MAGMA_LIBS)
  53.  
  54.  
  55. # ----------------------------------------
  56. # Fortran example
  57. # this uses capital .F90 to preprocess to define magma_devptr_t
  58. %.o: %.F90
  59.     $(FORT) $(F90FLAGS) $(MAGMA_F90FLAGS) -c -o $@ $<
  60.  
  61. fortran.o: $(CUDADIR)/src/fortran.c
  62.     $(CC) $(CFLAGS) $(MAGMA_CFLAGS) -DCUBLAS_GFORTRAN -c -o $@ $<
  63.  
  64. example_f: example_f.o fortran.o
  65.     $(FORT) $(LDFLAGS) -o $@ $^ $(MAGMA_LIBS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement