Browse Source

Merge branch 'master' of git+ssh://scm.gforge.inria.fr/gitroot/starpu/starpu

Samuel Thibault 5 years ago
parent
commit
27bf600876
100 changed files with 283 additions and 5 deletions
  1. 0 0
      julia/Makefile
  2. 0 0
      julia/Manifest.toml
  3. 0 0
      julia/Project.toml
  4. 53 0
      julia/README
  5. 0 0
      julia/REQUIRE
  6. 0 0
      julia/examples/black_scholes/black_scholes.c
  7. 0 0
      julia/examples/black_scholes/black_scholes.jl
  8. 1 1
      julia/mandelbrot/Makefile
  9. 0 0
      julia/examples/mandelbrot/cpu_mandelbrot.c
  10. 0 0
      julia/examples/mandelbrot/mandelbrot.c
  11. 0 0
      julia/examples/mandelbrot/mandelbrot.jl
  12. 0 0
      julia/examples/mandelbrot/mandelbrot_native.jl
  13. 0 0
      julia/examples/mult/Makefile
  14. 0 0
      julia/examples/mult/README
  15. 0 0
      julia/examples/mult/cpu_mult.c
  16. 0 0
      julia/examples/mult/gpu_mult.cu
  17. 0 0
      julia/examples/mult/mult.c
  18. 0 0
      julia/examples/mult/mult.jl
  19. 0 0
      julia/examples/mult/mult.plot
  20. 0 0
      julia/examples/mult/mult_native.jl
  21. 0 0
      julia/examples/mult/res/mult_cstarpu_gcc9_s72_2x2_b4x2.dat
  22. 0 0
      julia/examples/mult/res/mult_gen_gcc9_1x4.dat
  23. 0 0
      julia/examples/mult/res/mult_gen_gcc9_4x1.dat
  24. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s100_4x1.dat
  25. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s50_4x1.dat
  26. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s64_16x16_b4x2.dat
  27. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s64_4x4_b4x2.dat
  28. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s64_8x1_b4x2.dat
  29. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s64_8x8_b4x2.dat
  30. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_16x18_b4x2.dat
  31. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_16x8_b4x2.dat
  32. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_2x2.dat
  33. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_2x2_b4x2.dat
  34. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_2x2_b4x4.dat
  35. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_2x2_b8x2.dat
  36. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_4x1.dat
  37. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_4x4_b4x2.dat
  38. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s72_8x8_b4x2.dat
  39. 0 0
      julia/examples/mult/res/mult_gen_gcc9_s80_4x1.dat
  40. 0 0
      julia/examples/mult/res/mult_gen_icc_s72_2x1_b4x2.dat
  41. 0 0
      julia/examples/mult/res/mult_gen_icc_s72_4x4_b4x2.dat
  42. 0 0
      julia/examples/mult/res/mult_native.dat
  43. 0 0
      julia/examples/mult/res/mult_nogen_gcc9_s72_2x2_b2x2.dat
  44. 0 0
      julia/examples/mult/res/mult_nogen_gcc9_s72_2x2_b4x2.dat
  45. 0 0
      julia/examples/mult/res/mult_nogen_icc_s72-36_2x2_b4x2.dat
  46. 0 0
      julia/examples/mult/res/mult_nogen_icc_s72_2x2_b4x2.dat
  47. 0 0
      julia/examples/mult/res/mult_nogen_icc_s72x2_2x2_b4x2.dat
  48. 0 0
      julia/examples/old_examples/Makefile.mk
  49. 0 0
      julia/examples/old_examples/README
  50. 0 0
      julia/examples/old_examples/cpu_mult.c
  51. 0 0
      julia/examples/old_examples/gpu_mult.cu
  52. 0 0
      julia/examples/old_examples/includes/display.c
  53. 0 0
      julia/examples/old_examples/includes/display.h
  54. 0 0
      julia/examples/old_examples/includes/sorting.c
  55. 0 0
      julia/examples/old_examples/includes/sorting.h
  56. 0 0
      julia/examples/old_examples/mandelbrot/cpu_cuda_mandelbrot.jl
  57. 0 0
      julia/examples/old_examples/mandelbrot/cpu_mandelbrot.c
  58. 0 0
      julia/examples/old_examples/mandelbrot/cpu_mandelbrot_between.c
  59. 0 0
      julia/examples/old_examples/mandelbrot/gpu_mandelbrot.cu
  60. 0 0
      julia/examples/old_examples/mandelbrot/gpu_mandelbrot_between.cu
  61. 0 0
      julia/examples/old_examples/mandelbrot/mandelbrot.c
  62. 0 0
      julia/examples/old_examples/mandelbrot/mandelbrot.jl
  63. 0 0
      julia/examples/old_examples/mandelbrot/mandelbrot_between.c
  64. 0 0
      julia/examples/old_examples/mandelbrot/mandelbrot_def.jl
  65. 0 0
      julia/examples/old_examples/mandelbrot/mandelbrot_generated.jl
  66. 0 0
      julia/examples/old_examples/mult.c
  67. 0 0
      julia/examples/old_examples/mult/cpu_cuda_mult.jl
  68. 0 0
      julia/examples/old_examples/mult/cpu_mult.c
  69. 0 0
      julia/examples/old_examples/mult/gpu_mult.cu
  70. 0 0
      julia/examples/old_examples/mult/mult.c
  71. 0 0
      julia/examples/old_examples/mult/mult_def.jl
  72. 0 0
      julia/examples/old_examples/mult/mult_extern.jl
  73. 0 0
      julia/examples/old_examples/mult/mult_extern_graph.jl
  74. 0 0
      julia/examples/old_examples/mult/mult_generated.jl
  75. 0 0
      julia/examples/old_examples/mult/mult_generated_graph.jl
  76. 0 0
      julia/examples/old_examples/mult/mult_naive.jl
  77. 0 0
      julia/examples/old_examples/nbody/cpu_cuda_nbody.jl
  78. 0 0
      julia/examples/old_examples/nbody/cpu_nbody.c
  79. 0 0
      julia/examples/old_examples/nbody/cpu_nbody_between.c
  80. 0 0
      julia/examples/old_examples/nbody/gpu_nbody.cu
  81. 0 0
      julia/examples/old_examples/nbody/gpu_nbody_between.cu
  82. 0 0
      julia/examples/old_examples/nbody/nbody.c
  83. 0 0
      julia/examples/old_examples/nbody/nbody.jl
  84. 0 0
      julia/examples/old_examples/nbody/nbody_between.c
  85. 0 0
      julia/examples/old_examples/nbody/nbody_def.jl
  86. 0 0
      julia/examples/old_examples/nbody/nbody_display.jl
  87. 0 0
      julia/examples/old_examples/nbody/nbody_generated.jl
  88. 51 0
      julia/examples/task_insert_color/Makefile
  89. 89 0
      julia/examples/task_insert_color/task_insert_color.c
  90. 48 0
      julia/examples/task_insert_color/task_insert_color.jl
  91. 0 0
      julia/examples/variable/Makefile
  92. 0 0
      julia/examples/variable/variable.jl
  93. 0 0
      julia/examples/variable/variable_native.jl
  94. 0 0
      julia/examples/vector_scal/Makefile
  95. 0 0
      julia/examples/vector_scal/cpu_vector_scal.c
  96. 7 0
      julia/vector_scal/vector_scal.jl
  97. 7 0
      julia/setenv.sh
  98. 27 4
      julia/StarPU.jl/src/StarPU.jl
  99. 0 0
      julia/src/compiler/c.jl
  100. 0 0
      julia/StarPU.jl/src/compiler/cuda.jl

julia/StarPU.jl/Makefile → julia/Makefile


julia/StarPU.jl/Manifest.toml → julia/Manifest.toml


julia/StarPU.jl/Project.toml → julia/Project.toml


+ 53 - 0
julia/README

@@ -0,0 +1,53 @@
+Contents
+========
+
+* Installing Julia
+* Installing StarPU module for Julia
+* Running Examples
+
+Installing Julia
+----------------
+Julia version 1.3+ is required and can be downloaded from
+https://julialang.org/downloads/.
+
+
+Installing StarPU module for Julia
+----------------------------------
+First, build the jlstarpu_c_wrapper library:
+
+$ make
+
+Then, you need to add the lib/ directory to your library path and the julia/
+directory to your Julia load path:
+
+$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
+$ export JULIA_LOAD_PATH=$JULIA_LOAD_PATH:$PWD
+
+This step can also be done by sourcing the setenv.sh script:
+
+$ . setenv.sh
+
+Running Examples
+----------------
+
+You can find several examples in the examples/ directory.
+
+For each example X, three versions are provided:
+
+- X.c: Original C+starpu code
+- X_native.jl: Native Julia version (without StarPU)
+- X.jl: Julia version using StarPU
+
+
+To run the original C+StarPU code:
+$ make cstarpu.dat
+
+To run the native Julia version:
+$ make julia_native.dat
+
+To run the Julia version using StarPU:
+$ make julia_generatedc.dat
+
+
+
+

julia/StarPU.jl/REQUIRE → julia/REQUIRE


julia/black_scholes/black_scholes.c → julia/examples/black_scholes/black_scholes.c


julia/black_scholes/black_scholes.jl → julia/examples/black_scholes/black_scholes.jl


+ 1 - 1
julia/mandelbrot/Makefile

@@ -26,7 +26,7 @@ LIBPATH=${PWD}/../StarPU.jl/lib
 all: ${EXTERNLIB}
 
 mandelbrot: mandelbrot.c cpu_mandelbrot.o #gpu_mandelbrot.o
-	$(CC) $(CPU_CFLAGS) $^ -o $@ $(LDFLAGS)
+	$(CC) $(CPU_CFLAGS) $^ -o $@ $(LDFLAGS) -lm
 
 %.o: %.c
 	$(CC) -c -fPIC $(CPU_CFLAGS) $^ -o $@

julia/mandelbrot/cpu_mandelbrot.c → julia/examples/mandelbrot/cpu_mandelbrot.c


julia/mandelbrot/mandelbrot.c → julia/examples/mandelbrot/mandelbrot.c


julia/mandelbrot/mandelbrot.jl → julia/examples/mandelbrot/mandelbrot.jl


julia/mandelbrot/mandelbrot_native.jl → julia/examples/mandelbrot/mandelbrot_native.jl


julia/mult/Makefile → julia/examples/mult/Makefile


julia/mult/README → julia/examples/mult/README


julia/mult/cpu_mult.c → julia/examples/mult/cpu_mult.c


julia/mult/gpu_mult.cu → julia/examples/mult/gpu_mult.cu


julia/mult/mult.c → julia/examples/mult/mult.c


julia/mult/mult.jl → julia/examples/mult/mult.jl


julia/mult/mult.plot → julia/examples/mult/mult.plot


julia/mult/mult_native.jl → julia/examples/mult/mult_native.jl


julia/mult/res/mult_cstarpu_gcc9_s72_2x2_b4x2.dat → julia/examples/mult/res/mult_cstarpu_gcc9_s72_2x2_b4x2.dat


julia/mult/res/mult_gen_gcc9_1x4.dat → julia/examples/mult/res/mult_gen_gcc9_1x4.dat


julia/mult/res/mult_gen_gcc9_4x1.dat → julia/examples/mult/res/mult_gen_gcc9_4x1.dat


julia/mult/res/mult_gen_gcc9_s100_4x1.dat → julia/examples/mult/res/mult_gen_gcc9_s100_4x1.dat


julia/mult/res/mult_gen_gcc9_s50_4x1.dat → julia/examples/mult/res/mult_gen_gcc9_s50_4x1.dat


julia/mult/res/mult_gen_gcc9_s64_16x16_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s64_16x16_b4x2.dat


julia/mult/res/mult_gen_gcc9_s64_4x4_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s64_4x4_b4x2.dat


julia/mult/res/mult_gen_gcc9_s64_8x1_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s64_8x1_b4x2.dat


julia/mult/res/mult_gen_gcc9_s64_8x8_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s64_8x8_b4x2.dat


julia/mult/res/mult_gen_gcc9_s72_16x18_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s72_16x18_b4x2.dat


julia/mult/res/mult_gen_gcc9_s72_16x8_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s72_16x8_b4x2.dat


julia/mult/res/mult_gen_gcc9_s72_2x2.dat → julia/examples/mult/res/mult_gen_gcc9_s72_2x2.dat


julia/mult/res/mult_gen_gcc9_s72_2x2_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s72_2x2_b4x2.dat


julia/mult/res/mult_gen_gcc9_s72_2x2_b4x4.dat → julia/examples/mult/res/mult_gen_gcc9_s72_2x2_b4x4.dat


julia/mult/res/mult_gen_gcc9_s72_2x2_b8x2.dat → julia/examples/mult/res/mult_gen_gcc9_s72_2x2_b8x2.dat


julia/mult/res/mult_gen_gcc9_s72_4x1.dat → julia/examples/mult/res/mult_gen_gcc9_s72_4x1.dat


julia/mult/res/mult_gen_gcc9_s72_4x4_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s72_4x4_b4x2.dat


julia/mult/res/mult_gen_gcc9_s72_8x8_b4x2.dat → julia/examples/mult/res/mult_gen_gcc9_s72_8x8_b4x2.dat


julia/mult/res/mult_gen_gcc9_s80_4x1.dat → julia/examples/mult/res/mult_gen_gcc9_s80_4x1.dat


julia/mult/res/mult_gen_icc_s72_2x1_b4x2.dat → julia/examples/mult/res/mult_gen_icc_s72_2x1_b4x2.dat


julia/mult/res/mult_gen_icc_s72_4x4_b4x2.dat → julia/examples/mult/res/mult_gen_icc_s72_4x4_b4x2.dat


julia/mult/res/mult_native.dat → julia/examples/mult/res/mult_native.dat


julia/mult/res/mult_nogen_gcc9_s72_2x2_b2x2.dat → julia/examples/mult/res/mult_nogen_gcc9_s72_2x2_b2x2.dat


julia/mult/res/mult_nogen_gcc9_s72_2x2_b4x2.dat → julia/examples/mult/res/mult_nogen_gcc9_s72_2x2_b4x2.dat


julia/mult/res/mult_nogen_icc_s72-36_2x2_b4x2.dat → julia/examples/mult/res/mult_nogen_icc_s72-36_2x2_b4x2.dat


julia/mult/res/mult_nogen_icc_s72_2x2_b4x2.dat → julia/examples/mult/res/mult_nogen_icc_s72_2x2_b4x2.dat


julia/mult/res/mult_nogen_icc_s72x2_2x2_b4x2.dat → julia/examples/mult/res/mult_nogen_icc_s72x2_2x2_b4x2.dat


julia/tst/Makefile.mk → julia/examples/old_examples/Makefile.mk


julia/tst/README → julia/examples/old_examples/README


julia/tst/cpu_mult.c → julia/examples/old_examples/cpu_mult.c


julia/tst/gpu_mult.cu → julia/examples/old_examples/gpu_mult.cu


julia/tst/includes/display.c → julia/examples/old_examples/includes/display.c


julia/tst/includes/display.h → julia/examples/old_examples/includes/display.h


julia/tst/includes/sorting.c → julia/examples/old_examples/includes/sorting.c


julia/tst/includes/sorting.h → julia/examples/old_examples/includes/sorting.h


julia/tst/mandelbrot/cpu_cuda_mandelbrot.jl → julia/examples/old_examples/mandelbrot/cpu_cuda_mandelbrot.jl


julia/tst/mandelbrot/cpu_mandelbrot.c → julia/examples/old_examples/mandelbrot/cpu_mandelbrot.c


julia/tst/mandelbrot/cpu_mandelbrot_between.c → julia/examples/old_examples/mandelbrot/cpu_mandelbrot_between.c


julia/tst/mandelbrot/gpu_mandelbrot.cu → julia/examples/old_examples/mandelbrot/gpu_mandelbrot.cu


julia/tst/mandelbrot/gpu_mandelbrot_between.cu → julia/examples/old_examples/mandelbrot/gpu_mandelbrot_between.cu


julia/tst/mandelbrot/mandelbrot.c → julia/examples/old_examples/mandelbrot/mandelbrot.c


julia/tst/mandelbrot/mandelbrot.jl → julia/examples/old_examples/mandelbrot/mandelbrot.jl


julia/tst/mandelbrot/mandelbrot_between.c → julia/examples/old_examples/mandelbrot/mandelbrot_between.c


julia/tst/mandelbrot/mandelbrot_def.jl → julia/examples/old_examples/mandelbrot/mandelbrot_def.jl


julia/tst/mandelbrot/mandelbrot_generated.jl → julia/examples/old_examples/mandelbrot/mandelbrot_generated.jl


julia/tst/mult.c → julia/examples/old_examples/mult.c


julia/tst/mult/cpu_cuda_mult.jl → julia/examples/old_examples/mult/cpu_cuda_mult.jl


julia/tst/mult/cpu_mult.c → julia/examples/old_examples/mult/cpu_mult.c


julia/tst/mult/gpu_mult.cu → julia/examples/old_examples/mult/gpu_mult.cu


julia/tst/mult/mult.c → julia/examples/old_examples/mult/mult.c


julia/tst/mult/mult_def.jl → julia/examples/old_examples/mult/mult_def.jl


julia/tst/mult/mult_extern.jl → julia/examples/old_examples/mult/mult_extern.jl


julia/tst/mult/mult_extern_graph.jl → julia/examples/old_examples/mult/mult_extern_graph.jl


julia/tst/mult/mult_generated.jl → julia/examples/old_examples/mult/mult_generated.jl


julia/tst/mult/mult_generated_graph.jl → julia/examples/old_examples/mult/mult_generated_graph.jl


julia/tst/mult/mult_naive.jl → julia/examples/old_examples/mult/mult_naive.jl


julia/tst/nbody/cpu_cuda_nbody.jl → julia/examples/old_examples/nbody/cpu_cuda_nbody.jl


julia/tst/nbody/cpu_nbody.c → julia/examples/old_examples/nbody/cpu_nbody.c


julia/tst/nbody/cpu_nbody_between.c → julia/examples/old_examples/nbody/cpu_nbody_between.c


julia/tst/nbody/gpu_nbody.cu → julia/examples/old_examples/nbody/gpu_nbody.cu


julia/tst/nbody/gpu_nbody_between.cu → julia/examples/old_examples/nbody/gpu_nbody_between.cu


julia/tst/nbody/nbody.c → julia/examples/old_examples/nbody/nbody.c


julia/tst/nbody/nbody.jl → julia/examples/old_examples/nbody/nbody.jl


julia/tst/nbody/nbody_between.c → julia/examples/old_examples/nbody/nbody_between.c


julia/tst/nbody/nbody_def.jl → julia/examples/old_examples/nbody/nbody_def.jl


julia/tst/nbody/nbody_display.jl → julia/examples/old_examples/nbody/nbody_display.jl


julia/tst/nbody/nbody_generated.jl → julia/examples/old_examples/nbody/nbody_generated.jl


+ 51 - 0
julia/examples/task_insert_color/Makefile

@@ -0,0 +1,51 @@
+CC=gcc
+NVCC=nvcc
+ENABLE_CUDA=no
+LD=$(CC)
+
+ifeq ($(ENABLE_CUDA),yes)
+        LD := ${NVCC}
+endif
+
+CFLAGS = -O3 -g $(shell pkg-config --cflags starpu-1.3)
+CPU_CFLAGS = ${CFLAGS} -Wall -mavx -fomit-frame-pointer -march=native -ffast-math
+CUDA_CFLAGS = ${CFLAGS}
+LDFLAGS +=$(shell pkg-config --libs starpu-1.3)
+
+EXTERNLIB=extern_tasks.so
+GENERATEDLIB=generated_tasks.so
+
+C_OBJECTS=$(patsubst %.c,%.o,$(wildcard gen*.c))
+CUDA_OBJECTS=$(patsubst %.cu,%.o,$(wildcard gen*.cu))
+ifneq ($(ENABLE_CUDA),yes)
+	CUDA_OBJECTS:=
+endif
+
+LIBPATH=${PWD}/../StarPU.jl/lib
+
+all: task_insert_color
+
+task_insert_color: task_insert_color.o
+	$(CC) $(CPU_CFLAGS) $^ -o $@ $(LDFLAGS)
+
+%.o: %.c
+	$(CC) -c -fPIC $(CPU_CFLAGS) $^ -o $@
+
+%.o: %.cu
+	$(NVCC) -dc $(CUDA_CFLAGS) $^ --shared --compiler-options '-fPIC' -o $@ $(LDFLAGS)
+
+${GENERATEDLIB}: $(C_OBJECTS) $(CUDA_OBJECTS)
+	$(LD) -shared $(LDFLAGS) $^ -o $@
+
+PHONY: clean
+
+clean:
+	rm -f vector_scal *.so *.o genc_*.c gencuda_*.cu *.dat
+
+# Performance Tests
+cstarpu.dat: task_insert_color
+	STARPU_NOPENCL=0 STARPU_SCHED=dmda STARPU_CALIBRATE=1 ./task_insert_color > $@
+julia_generatedc.dat:
+	LD_LIBRARY_PATH+=${LIBPATH} STARPU_NOPENCL=0 STARPU_SCHED=dmda STARPU_CALIBRATE=1 julia task_insert_colorl.jl
+
+test: cstarpu.dat julia_generatedc.dat

+ 89 - 0
julia/examples/task_insert_color/task_insert_color.c

@@ -0,0 +1,89 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2018-2020  Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include <starpu.h>
+
+#define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
+
+void func(void *descr[], void *_args)
+{
+	int *x = (int *)STARPU_VARIABLE_GET_PTR(descr[0]);
+	(void)_args;
+
+	*x *= 2;
+}
+
+struct starpu_codelet mycodelet =
+{
+	.modes = { STARPU_RW },
+	.cpu_funcs = {func},
+	.cpu_funcs_name = {"func"},
+        .nbuffers = 1
+};
+
+struct starpu_codelet mycodelet_color =
+{
+	.modes = { STARPU_RW },
+	.cpu_funcs = {func},
+	.cpu_funcs_name = {"func"},
+        .nbuffers = 1,
+	.color = 0x0000FF,
+};
+
+int main(void)
+{
+	unsigned i;
+	int value=42;
+	starpu_data_handle_t handle;
+	int ret;
+
+	ret = starpu_init(NULL);
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
+	starpu_variable_data_register(&handle, STARPU_MAIN_RAM, (uintptr_t)&value, sizeof(value));
+
+	// In the trace file, the following task should be green (executed on CPU)
+	ret = starpu_task_insert(&mycodelet, STARPU_RW, handle, STARPU_NAME, "mytask",
+				 0);
+	if (STARPU_UNLIKELY(ret == -ENODEV))
+	{
+		starpu_data_unregister(handle);
+		goto enodev;
+	}
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
+
+	// In the trace file, the following task will be red as specified by STARPU_TASK_COLOR
+	ret = starpu_task_insert(&mycodelet, STARPU_RW, handle, STARPU_NAME, "mytask",
+				 STARPU_TASK_COLOR, 0xFF0000,
+				 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
+
+	// In the trace file, the following task will be blue as specified by the field color of mycodelet_color
+	ret = starpu_task_insert(&mycodelet_color, STARPU_RW, handle, STARPU_NAME, "mytask",
+				 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
+
+	starpu_task_wait_for_all();
+	starpu_data_unregister(handle);
+
+	starpu_shutdown();
+
+	return 0;
+
+ enodev:
+	return 77;
+}

+ 48 - 0
julia/examples/task_insert_color/task_insert_color.jl

@@ -0,0 +1,48 @@
+import Libdl
+using StarPU
+
+@target STARPU_CPU
+@codelet function task_insert_color(val ::Ref{Int32}) :: Nothing
+    val[] = val[] * 2
+
+    return
+end
+
+starpu_init()
+
+function task_insert_color_with_starpu(val ::Ref{Int32})
+    @starpu_block let
+	hVal = starpu_data_register(val)
+
+        cl1 = StarpuCodelet(
+            cpu_func = CPU_CODELETS["task_insert_color"],
+            modes = [STARPU_RW]
+        )
+
+        cl2 = StarpuCodelet(
+            cpu_func = CPU_CODELETS["task_insert_color"],
+            modes = [STARPU_RW],
+            color = 0x0000FF
+        )
+
+	@starpu_sync_tasks begin
+
+            # In the trace file, the following task should be green (executed on CPU)
+            starpu_task_submit(StarpuTask(cl = cl1, handles = [hVal]))
+
+            # In the trace file, the following task will be blue as specified by the field color of cl2
+            starpu_task_submit(StarpuTask(cl = cl2, handles = [hVal]))
+
+            # In the trace file, the following tasks will be red as specified in @starpu_async_cl
+            @starpu_async_cl task_insert_color(hVal) [STARPU_RW] [] 0xFF0000
+
+	end
+    end
+end
+
+
+foo = Ref(convert(Int32, 42))
+
+task_insert_color_with_starpu(foo)
+
+starpu_shutdown()

julia/variable/Makefile → julia/examples/variable/Makefile


julia/variable/variable.jl → julia/examples/variable/variable.jl


julia/variable/variable_native.jl → julia/examples/variable/variable_native.jl


julia/vector_scal/Makefile → julia/examples/vector_scal/Makefile


julia/vector_scal/cpu_vector_scal.c → julia/examples/vector_scal/cpu_vector_scal.c


+ 7 - 0
julia/vector_scal/vector_scal.jl

@@ -55,11 +55,18 @@ end
 function compute_times(io,start_dim, step_dim, stop_dim)
     for size in (start_dim : step_dim : stop_dim)
         V = Array(rand(Cfloat, size))
+        starpu_memory_pin(V)
+
         m :: Int32 = 10
         k :: Float32 = 2.
         l :: Float32 = 3.
+
         println("INPUT ", V[1:10])
+
         mt =  vector_scal_with_starpu(V, m, k, l)
+
+        starpu_memory_unpin(V)
+
         println("OUTPUT ", V[1:10])
         println(io,"$size $mt")
         println("$size $mt")

+ 7 - 0
julia/setenv.sh

@@ -0,0 +1,7 @@
+export JULIA_LOAD_PATH=$JULIA_LOAD_PATH:$PWD
+
+if [ `uname` == "Darwin" ]; then
+    export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$PWD/lib/
+else
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib/
+fi

+ 27 - 4
julia/StarPU.jl/src/StarPU.jl

@@ -49,6 +49,8 @@ end
 
 export starpu_init
 export starpu_shutdown
+export starpu_memory_pin
+export starpu_memory_unpin
 export starpu_data_unregister
 export starpu_data_register
 export starpu_data_get_sub_data
@@ -185,6 +187,8 @@ end
 struct StarpuCodelet
     where_to_execute :: UInt32
 
+    color :: UInt32
+
     cpu_func :: String
     cuda_func :: String
     opencl_func :: String
@@ -201,7 +205,8 @@ struct StarpuCodelet
                            opencl_func :: String = "",
                            modes :: Vector{StarpuDataAccessMode} = StarpuDataAccessMode[],
                            perfmodel :: StarpuPerfmodel = StarpuPerfmodel(),
-                           where_to_execute :: Union{Cvoid, UInt32} = nothing
+                           where_to_execute :: Union{Cvoid, UInt32} = nothing,
+                           color :: UInt32 = 0x00000000
                            )
 
         if (length(modes) > STARPU_NMAXBUFS)
@@ -217,7 +222,7 @@ struct StarpuCodelet
             real_where = where_to_execute
         end
 
-        output = new(real_where, cpu_func, cuda_func, opencl_func,modes, perfmodel, real_c_codelet_ptr)
+        output = new(real_where, color, cpu_func, cuda_func, opencl_func,modes, perfmodel, real_c_codelet_ptr)
 
         starpu_c_codelet_update(output)
 
@@ -651,9 +656,23 @@ end
 
 STARPU_MAIN_RAM = 0 #TODO: ENUM
 
+function starpu_memory_pin(data) :: Nothing
+    data_pointer = pointer(data)
 
+    @starpucall(starpu_memory_pin,
+                Cvoid, (Ptr{Cvoid}, Csize_t),
+                data_pointer,
+                sizeof(data))
+end
 
+function starpu_memory_unpin(data) :: Nothing
+    data_pointer = pointer(data)
 
+    @starpucall(starpu_memory_unpin,
+                Cvoid, (Ptr{Cvoid}, Csize_t),
+                data_pointer,
+                sizeof(data))
+end
 
 function StarpuNewDataHandle(ptr :: StarpuDataHandlePointer, destr :: Function...) :: StarpuDataHandle
     return StarpuDestructible(ptr, destr...)
@@ -858,7 +877,7 @@ end
     Creates and submits an asynchronous task running cl Codelet function.
     Ex : @starpu_async_cl cl(handle1, handle2)
 """
-macro starpu_async_cl(expr,modes,cl_arg=[])
+macro starpu_async_cl(expr, modes, cl_arg=[], color ::UInt32=0x00000000)
 
     if (!isa(expr, Expr) || expr.head != :call)
         error("Invalid task submit syntax")
@@ -877,7 +896,8 @@ macro starpu_async_cl(expr,modes,cl_arg=[])
         #opencl_func="ocl_matrix_mult",
         ### TODO: CORRECT !
         modes = map((x -> starpu_modes(x)),modes.args),
-        perfmodel = perfmodel
+        perfmodel = perfmodel,
+        color = color
     )
     handles = Expr(:vect, expr.args[2:end]...)
     #dump(handles)
@@ -1214,6 +1234,8 @@ mutable struct StarpuCodeletTranslator
 
     where_to_execute :: UInt32
 
+    color :: UInt32
+
     cpu_func :: Ptr{Cvoid}
     cpu_func_name :: Cstring
 
@@ -1237,6 +1259,7 @@ mutable struct StarpuCodeletTranslator
         end
 
         output.where_to_execute = cl.where_to_execute
+        output.color = cl.color
 
         cpu_func_ptr = load_starpu_function_pointer(cl.cpu_func)
         cuda_func_ptr = load_starpu_function_pointer(cl.cuda_func)

julia/StarPU.jl/src/compiler/c.jl → julia/src/compiler/c.jl


+ 0 - 0
julia/StarPU.jl/src/compiler/cuda.jl


Some files were not shown because too many files changed in this diff