Guest User

Untitled

a guest
Apr 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "RInside.h"
  3. #include "hemi/parallel_for.h"
  4.  
  5. using namespace hemi;
  6.  
  7. int main(void)
  8. {
  9. parallel_for(0, 100, [] HEMI_LAMBDA (int i) {
  10. printf("%dn", i);
  11. });
  12.  
  13. deviceSynchronize();
  14.  
  15. return 0;
  16. }
  17.  
  18. # operating system
  19. HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
  20.  
  21. # architecture
  22. ARCH := $(shell getconf LONG_BIT)
  23.  
  24. NVCC := nvcc
  25.  
  26. ifeq ($(HOST_OS),darwin)
  27. CXX := clang++
  28. else
  29. CXX := g++
  30. endif
  31.  
  32. STD := --std=c++11
  33.  
  34. CXX_FLAGS := $(STD) -I../ -I../../
  35.  
  36. HOST_ONLY_FLAGS := -DHEMI_CUDA_DISABLE
  37.  
  38. # uncomment for debug
  39. #DEBUG_FLAGS := -g -DDEBUG
  40. #DEBUG_FLAGS_NVCC := -G
  41.  
  42. # comment for debug
  43. CXX_FLAGS += -O3
  44.  
  45. CXX_FLAGS += $(DEBUG_FLAGS)
  46.  
  47. NVCC_FLAGS := $(CXX_FLAGS) $(DEBUG_FLAGS_NVCC) --expt-extended-lambda
  48.  
  49. all: parallel_for_device parallel_for_host parallel_for_host_nvcc
  50.  
  51. parallel_for_device: parallel_for.cpp
  52. $(NVCC) $? $(NVCC_FLAGS) -x cu -o $@
  53.  
  54. parallel_for_host_nvcc: parallel_for.cpp
  55. $(NVCC) $? $(CXX_FLAGS) -x c++ -o $@
  56.  
  57. parallel_for_host: parallel_for.cpp
  58. $(CXX) $? $(CXX_FLAGS) $(HOST_ONLY_FLAGS) -o $@
  59.  
  60. clean:
  61. rm -rf parallel_for_device parallel_for_host_nvcc parallel_for_host
Add Comment
Please, Sign In to add comment