Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # StarPU --- Runtime system for heterogeneous multicore architectures.
  2. #
  3. # Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. #
  5. # StarPU is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; either version 2.1 of the License, or (at
  8. # your option) any later version.
  9. #
  10. # StarPU is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. #
  16. STARPU ?= undefined
  17. EXAMPLE ?= undefined
  18. TARGETS = hello_world
  19. TARGETS += block
  20. TARGETS += mult
  21. TARGETS += variable
  22. TARGETS += incrementer
  23. ifeq ($(STARPU),undefined)
  24. all:
  25. @echo
  26. @echo "ERROR. You need to set the variable STARPU to the name of the pkg-config StarPU package"
  27. @echo
  28. clean:; rm -f $(TARGETS) *.o
  29. else
  30. ifeq ($(EXAMPLE),undefined)
  31. all:
  32. @echo
  33. @echo "ERROR. You need to set the variable EXAMPLE to the directory hosting the example sources"
  34. @echo
  35. clean:; rm -f $(TARGETS) *.o
  36. else
  37. CFLAGS += $$(pkg-config --cflags $(STARPU))
  38. LDFLAGS += $$(pkg-config --libs $(STARPU))
  39. HAS_CUDA = $(shell pkg-config --libs $(STARPU) |grep -i cuda)
  40. NVCC ?= nvcc
  41. HAS_OPENCL = $(shell pkg-config --libs $(STARPU) |grep -i opencl)
  42. %.o: $(EXAMPLE)/basic_examples/%.cu
  43. $(NVCC) $(CFLAGS) $< -c
  44. %.o: $(EXAMPLE)/basic_examples/%.c
  45. $(CC) $(CFLAGS) $< -c
  46. %.o: $(EXAMPLE)/incrementer/%.cu
  47. $(NVCC) $(CFLAGS) $< -c
  48. %.o: $(EXAMPLE)/incrementer/%.c
  49. $(CC) $(CFLAGS) $< -c
  50. all: $(TARGETS)
  51. BLOCK_PREREQUISITES = block.o block_cpu.o
  52. ifneq ($(strip $(HAS_CUDA)),)
  53. BLOCK_PREREQUISITES += block_cuda.o
  54. BLOCK_COMPILER = $(NVCC)
  55. else
  56. BLOCK_COMPILER = $(CC)
  57. endif
  58. ifneq ($(strip $(HAS_OPENCL)),)
  59. BLOCK_PREREQUISITES += block_opencl.o
  60. endif
  61. block: $(BLOCK_PREREQUISITES)
  62. $(BLOCK_COMPILER) $(LDFLAGS) $^ -o $@
  63. VARIABLE_PREREQUISITES = variable.o variable_kernels_cpu.o
  64. ifneq ($(strip $(HAS_CUDA)),)
  65. VARIABLE_PREREQUISITES += variable_kernels.o
  66. VARIABLE_COMPILER = $(NVCC)
  67. else
  68. VARIABLE_COMPILER = $(CC)
  69. endif
  70. ifneq ($(strip $(HAS_OPENCL)),)
  71. VARIABLE_PREREQUISITES += variable_kernels_opencl.o
  72. endif
  73. variable: $(VARIABLE_PREREQUISITES)
  74. $(VARIABLE_COMPILER) $(LDFLAGS) $^ -o $@
  75. INCREMENTER_PREREQUISITES = incrementer.o
  76. ifneq ($(strip $(HAS_CUDA)),)
  77. INCREMENTER_PREREQUISITES += incrementer_kernels.o
  78. INCREMENTER_COMPILER = $(NVCC)
  79. else
  80. INCREMENTER_COMPILER = $(CC)
  81. endif
  82. ifneq ($(strip $(HAS_OPENCL)),)
  83. INCREMENTER_PREREQUISITES += incrementer_kernels_opencl.o
  84. endif
  85. incrementer: $(INCREMENTER_PREREQUISITES)
  86. $(INCREMENTER_COMPILER) $(LDFLAGS) $^ -o $@
  87. clean:; rm -f $(TARGETS) *.o
  88. endif
  89. endif