瀏覽代碼

- integrate Fortran90 example contributed by ONERA

Olivier Aumage 10 年之前
父節點
當前提交
080f882056

+ 9 - 1
configure.ac

@@ -4,6 +4,7 @@
 # Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
 # Copyright (C) 2011  Télécom-SudParis
 # Copyright (C) 2011, 2012, 2014  INRIA
+# Copyright (C) 2015  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
@@ -76,6 +77,7 @@ AC_PROG_CPP
 AC_PROG_SED
 AC_PROG_LN_S
 AC_PROG_F77
+AC_PROG_FC
 AC_CHECK_PROGS(PROG_STAT,gstat stat)
 AC_CHECK_PROGS(PROG_DATE,gdate date)
 
@@ -646,7 +648,7 @@ if test x$enable_cuda = xyes; then
 	STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lcuda"
 	STARPU_CUFFT_LDFLAGS="-lcufft"
 
-        if test "$F77" = "gfortran" ; then
+        if test "$F77" = "gfortran" -o "$FC" = "gfortran" ; then
             STARPU_CUDA_FORTRAN_LDFLAGS="-lgfortran"
             AC_SUBST(STARPU_CUDA_FORTRAN_LDFLAGS)
         fi
@@ -2457,6 +2459,12 @@ if test "$enable_cuda" = "yes" -a "$ICC" != ""; then
    CFLAGS="$OLD_CFLAGS"
 fi
 
+# Fortran compiler
+if test "x$FC" != "x"; then
+  AC_DEFINE(STARPU_HAVE_FC, [], [Define this if a Fortran compiler is available])
+fi
+AM_CONDITIONAL([STARPU_HAVE_FC], [test "x$FC" != "x"])
+
 # Disable ICC on windows
 if test "x$ICC" != "x" -a "$starpu_windows" = "yes" ; then
     ICC=""

+ 32 - 0
examples/Makefile.am

@@ -4,6 +4,7 @@
 # Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
 # Copyright (C) 2011  Télécom-SudParis
 # Copyright (C) 2011-2012  INRIA
+# Copyright (C) 2015  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
@@ -215,6 +216,11 @@ STARPU_EXAMPLES +=				\
 	basic_examples/vector_scal_fortran	\
 	fortran/hello
 endif
+
+if STARPU_HAVE_FC
+STARPU_EXAMPLES +=				\
+	fortran90/f90_example
+endif
 endif
 
 if !NO_BLAS_LIB
@@ -321,6 +327,17 @@ fortran_hello_SOURCES	=		\
 	fortran/StarPU_fortran.h
 endif
 
+if STARPU_HAVE_FC
+fortran90_f90_example_SOURCES =	\
+	fortran90/mod_types.f90		\
+	fortran90/mod_interface.f90	\
+	fortran90/mod_compute.f90	\
+	fortran90/marshalling.c		\
+	fortran90/f90_example.f90
+
+fortran90_f90_example_FCFLAGS = -fdefault-real-8 -J$(top_builddir)/examples
+endif
+
 #######################
 # Multiformat example #
 #######################
@@ -910,3 +927,18 @@ showcheck:
 	done ; \
 	exit $$RET
 
+if STARPU_HAVE_FC
+# Fortran90 example
+# - list explicit dependences to control proper module files generation
+# - the overriding rule fully disables the corresponing default rule, thus
+#   the default rule body must be copied entirely
+mod_types.mod: fortran90_f90_example-mod_types.o
+mod_compute.mod: fortran90_f90_example-mod_compute.o
+mod_interface.mod: fortran90_f90_example-mod_interface.o
+
+fortran90_f90_example-mod_compute.o: fortran90/mod_compute.f90 mod_types.mod mod_interface.mod
+	$(AM_V_FC)$(FC) $(fortran90_f90_example_FCFLAGS) $(FCFLAGS) -c -o fortran90_f90_example-mod_compute.o `test -f 'fortran90/mod_compute.f90' || echo '$(srcdir)/'`fortran90/mod_compute.f90
+
+fortran90_f90_example-f90_example.o: fortran90/f90_example.f90 mod_types.mod mod_interface.mod mod_compute.mod
+	$(AM_V_FC)$(FC) $(fortran90_f90_example_FCFLAGS) $(FCFLAGS) -c -o fortran90_f90_example-f90_example.o `test -f 'fortran90/f90_example.f90' || echo '$(srcdir)/'`fortran90/f90_example.f90
+endif

+ 51 - 0
examples/fortran90/Makefile

@@ -0,0 +1,51 @@
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+#
+# Copyright (C) 2015  ONERA
+# Copyright (C) 2015  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.
+
+PROG = f90_example
+
+SRCSF = mod_types.f90		\
+	mod_interface.f90	\
+	mod_compute.f90		\
+	f90_example.f90
+SRCSC = marshalling.c
+
+FC = gfortran
+CC = gcc
+
+CFLAGS = -g $(shell pkg-config --cflags starpu-1.3)
+FCFLAGS = -fdefault-real-8 -J. -g
+LDLIBS =  $(shell pkg-config --libs starpu-1.3)
+
+OBJS = $(SRCSC:%.c=%.o) $(SRCSF:%.f90=%.o)
+
+.phony: all clean
+all: $(PROG)
+
+$(PROG): $(OBJS)
+	$(FC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+
+%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+%.o: %.f90
+	$(FC) $(FCFLAGS) -c -o $@ $<
+
+clean:
+	rm -fv *.o *.mod $(PROG)
+
+# modfiles generation dependences
+mod_compute.o: mod_compute.f90 mod_types.o mod_interface.o
+f90_example.o: f90_example.f90 mod_types.o mod_interface.o mod_compute.o

+ 134 - 0
examples/fortran90/f90_example.f90

@@ -0,0 +1,134 @@
+! StarPU --- Runtime system for heterogeneous multicore architectures.
+!
+! Copyright (C) 2015  ONERA
+! Copyright (C) 2015  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.
+
+PROGRAM f90_example
+
+  USE mod_types
+  USE mod_interface
+  USE mod_compute
+  USE iso_c_binding
+
+  IMPLICIT NONE
+
+  TYPE(type_mesh)                :: mesh
+  TYPE(type_numpar)              :: numpar
+  TYPE(type_mesh_elt),POINTER    :: elt   => NULL()
+  INTEGER                        :: i,Nelt,res
+  INTEGER                        :: neq,ng,nb,it,it_tot
+  REAL                           :: r, coeff2
+
+  !Initialization with arbitrary data
+  Nelt           = 2
+  it_tot = 2
+  numpar%Neq_max = 5
+  numpar%coeff   = 1.0
+  ALLOCATE(mesh%elt(Nelt))
+  DO i = 1,Nelt
+     elt => mesh%elt(i)
+     elt%Ng  = 4
+     elt%Np  = 2
+     ALLOCATE(elt%ro(numpar%Neq_max,elt%Np))
+     ALLOCATE(elt%dro(numpar%Neq_max,elt%Np))
+     ALLOCATE(elt%basis(elt%Np,elt%Ng))
+     CALL init_element(elt%ro,elt%dro,elt%basis,numpar%Neq_max,elt%Np,elt%Ng,i)
+  ENDDO
+
+  !Initialization of StarPU
+  res = starpu_init_c()
+
+  !Registration of elements
+  DO i = 1,Nelt
+     elt => mesh%elt(i)
+     CALL starpu_register_element_c(numpar%Neq_max,elt%Np,elt%Ng,elt%ro,elt%dro, &
+                                    elt%basis,elt%ro_h,elt%dro_h,elt%basis_h)
+  ENDDO
+  !Compute
+  DO it = 1,it_tot
+
+     ! compute new dro for each element
+     DO i = 1,Nelt
+        elt => mesh%elt(i)
+        CALL starpu_loop_element_task_c(numpar%coeff,elt%ro_h,elt%dro_h,elt%basis_h)
+     ENDDO
+     ! sync (if needed by the algorithm)
+     CALL starpu_task_wait_for_all_c()
+
+     ! - - - - -
+
+     ! copy dro to ro for each element
+     DO i = 1,Nelt
+        elt => mesh%elt(i)
+         CALL starpu_copy_element_task_c(elt%ro_h,elt%dro_h)
+     ENDDO
+     ! sync (if needed by the algorithm)
+     CALL starpu_task_wait_for_all_c()
+
+  ENDDO
+  !Unregistration of elements
+  DO i = 1,Nelt
+     elt => mesh%elt(i)
+     CALL starpu_unregister_element_c(elt%ro_h,elt%dro_h,elt%basis_h)
+  ENDDO
+
+  !Terminate StarPU, no task can be submitted after
+  CALL starpu_shutdown_c()
+
+  !Check data with StarPU
+  WRITE(6,'(a)') " "
+  WRITE(6,'(a)') " %%%% RESULTS STARPU %%%% "
+  WRITE(6,'(a)') " "
+  DO i = 1,Nelt
+     WRITE(6,'(a,i4,a)')      " elt ", i , "  ;  elt%ro = "
+     WRITE(6,'(10(1x,F11.2))') mesh%elt(i)%ro
+     WRITE(6,'(a)')           " ------------------------ "
+  ENDDO
+
+  !Same compute without StarPU
+  DO i = 1,Nelt
+     elt => mesh%elt(i)
+     CALL init_element(elt%ro,elt%dro,elt%basis,numpar%Neq_max,elt%Np,elt%Ng,i)
+  ENDDO
+
+  DO it = 1, it_tot
+     DO i = 1,Nelt
+        elt => mesh%elt(i)
+        CALL loop_element_cpu(elt%ro,elt%dro,elt%basis,numpar%coeff,numpar%Neq_max,elt%Ng,elt%Np)
+        elt%ro = elt%ro + elt%dro
+     ENDDO
+  ENDDO
+
+  WRITE(6,'(a)') " "
+  WRITE(6,'(a)') " %%%% RESULTS VERIFICATION %%%% "
+  WRITE(6,'(a)') " "
+
+  DO i = 1,Nelt
+     WRITE(6,'(a,i4,a)')      " elt ", i , "  ;  elt%ro = "
+     WRITE(6,'(10(1x,F11.2))') mesh%elt(i)%ro
+     WRITE(6,'(a)')           " ------------------------ "
+  ENDDO
+
+  WRITE(6,'(a)') " "
+
+  !Deallocation
+  DO i = 1,Nelt
+     elt => mesh%elt(i)
+     DEALLOCATE(elt%ro)
+     DEALLOCATE(elt%dro)
+     DEALLOCATE(elt%basis)
+  ENDDO
+  DEALLOCATE(mesh%elt)
+
+END PROGRAM f90_example

+ 173 - 0
examples/fortran90/marshalling.c

@@ -0,0 +1,173 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2015  ONERA
+ * Copyright (C) 2015  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>
+
+//--------------------------------------------------------------//
+void starpu_register_element_c(int Neq_max,int Np, int Ng,double **ro, double **dro,
+                               double **basis, void **ro_h, void **dro_h, void **basis_h){
+     starpu_data_handle_t ro_handle;
+     starpu_data_handle_t dro_handle;
+     starpu_data_handle_t basis_handle;
+
+     starpu_matrix_data_register(&ro_handle, 0, 
+        (uintptr_t)ro,Neq_max,Neq_max,Np, sizeof(double));
+     starpu_matrix_data_register(&dro_handle, 0, 
+        (uintptr_t)dro,Neq_max,Neq_max,Np, sizeof(double));
+     starpu_matrix_data_register(&basis_handle, 0, 
+        (uintptr_t)basis,Np,Np,Ng, sizeof(double));
+
+     *ro_h = ro_handle;
+     *dro_h = dro_handle;
+     *basis_h = basis_handle;
+}
+
+void starpu_unregister_element_c(void **ro_h, void **dro_h, void **basis_h){
+     starpu_data_handle_t ro_handle = *ro_h;
+     starpu_data_handle_t dro_handle = *dro_h;
+     starpu_data_handle_t basis_handle = *basis_h;
+
+     starpu_data_unregister(ro_handle);
+     starpu_data_unregister(dro_handle);
+     starpu_data_unregister(basis_handle);
+}
+
+//--------------------------------------------------------------//
+void loop_element_cpu_fortran(double coeff, int Neq_max, int Np,
+     int Ng, void *ro_ptr, void *dro_ptr, void *basis_ptr, void *cl_arg);
+
+void loop_element_cpu_func(void *buffers[], void *cl_arg);
+
+struct starpu_codelet cl_loop_element =
+{
+     .where = STARPU_CPU,
+     .cpu_funcs = {loop_element_cpu_func, NULL},
+     .nbuffers = 3,
+     .modes = {STARPU_R,STARPU_RW,STARPU_R},
+     .name = "LOOP_ELEMENT"
+};
+
+void loop_element_cpu_func(void *buffers[], void *cl_arg)
+{
+      double coeff;
+
+      double **ro = (double **) STARPU_MATRIX_GET_PTR(buffers[0]);
+      int Neq_max  = STARPU_MATRIX_GET_NX(buffers[0]);
+
+      double **dro = (double **) STARPU_MATRIX_GET_PTR(buffers[1]);
+
+      double **basis = (double **) STARPU_MATRIX_GET_PTR(buffers[2]);
+      int Np = STARPU_MATRIX_GET_NX(buffers[2]);
+      int Ng = STARPU_MATRIX_GET_NY(buffers[2]);
+
+      starpu_codelet_unpack_args(cl_arg, &coeff);
+
+      void *ro_ptr    = &ro;
+      void *dro_ptr   = &dro;
+      void *basis_ptr = &basis;
+
+      loop_element_cpu_fortran(coeff,Neq_max,Np,Ng, 
+                    ro_ptr,dro_ptr,basis_ptr,cl_arg);
+}
+
+void starpu_loop_element_task_c(double coeff, void **ro_h, void **dro_h, void **basis_h)
+{
+     int ret;
+
+     starpu_data_handle_t ro_handle = *ro_h;
+     starpu_data_handle_t dro_handle = *dro_h;
+     starpu_data_handle_t basis_handle = *basis_h;
+
+     struct starpu_task *task = starpu_task_create();
+
+     /* execute the task on any eligible computational ressource */
+     ret = starpu_insert_task(&cl_loop_element, 
+                        STARPU_VALUE,   &coeff, sizeof(double),
+                        STARPU_R,    ro_handle,
+                        STARPU_RW,   dro_handle,
+                        STARPU_R,    basis_handle,
+                        0);
+
+     /* verification */
+     if (ret != -ENODEV) STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+}
+
+//--------------------------------------------------------------//
+void copy_element_cpu_fortran(int Neq_max, int Np,
+     void *ro_ptr, void *dro_ptr);
+
+void copy_element_cpu_func(void *buffers[], void *cl_arg);
+
+struct starpu_codelet cl_copy_element =
+{
+     .where = STARPU_CPU,
+     .cpu_funcs = {copy_element_cpu_func, NULL},
+     .nbuffers = 2,
+     .modes = {STARPU_RW,STARPU_R},
+     .name = "COPY_ELEMENT"
+};
+
+void copy_element_cpu_func(void *buffers[], void *cl_arg)
+{
+      double **ro = (double **) STARPU_MATRIX_GET_PTR(buffers[0]);
+      int Neq_max  = STARPU_MATRIX_GET_NX(buffers[0]);
+      int Np = STARPU_MATRIX_GET_NY(buffers[0]);
+
+      double **dro = (double **) STARPU_MATRIX_GET_PTR(buffers[1]);
+
+      void *ro_ptr    = &ro;
+      void *dro_ptr   = &dro;
+
+      copy_element_cpu_fortran(Neq_max,Np,ro_ptr,dro_ptr);
+}
+
+void starpu_copy_element_task_c(void **ro_h, void **dro_h)
+{
+     int ret;
+
+     starpu_data_handle_t ro_handle = *ro_h;
+     starpu_data_handle_t dro_handle = *dro_h;
+
+     struct starpu_task *task = starpu_task_create();
+
+     /* execute the task on any eligible computational ressource */
+     ret = starpu_insert_task(&cl_copy_element, 
+                        STARPU_RW,  ro_handle,
+                        STARPU_R,   dro_handle,
+                        0);
+
+     /* verification */
+     if (ret != -ENODEV) STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+}
+
+//--------------------------------------------------------------//
+int starpu_init_c()
+{
+     /* Initialize StarPU with default configuration */
+     int ret;
+     struct starpu_conf conf;
+     starpu_conf_init(&conf);
+     conf.sched_policy_name = "dmda";
+
+     ret = starpu_init(&conf);
+     /*     int ret = starpu_init(NULL); */
+     if (ret == -ENODEV) goto enodev;
+
+     return ret;
+enodev:
+     return 77;
+}

+ 124 - 0
examples/fortran90/mod_compute.f90

@@ -0,0 +1,124 @@
+! StarPU --- Runtime system for heterogeneous multicore architectures.
+!
+! Copyright (C) 2015  ONERA
+! Copyright (C) 2015  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.
+
+MODULE mod_compute
+
+  USE mod_types
+  USE mod_interface
+  USE iso_c_binding
+
+  IMPLICIT NONE
+
+CONTAINS
+
+  !--------------------------------------------------------------!
+  SUBROUTINE init_element(ro,dro,basis,Neq_max,Np,Ng,i)
+    INTEGER,INTENT(IN)                        :: Neq_max,Np,Ng,i
+    REAL,DIMENSION(:,:),POINTER,INTENT(INOUT) :: ro,basis,dro
+    !Local variables
+    INTEGER                                   :: n,nb,neq
+
+    DO nb=1,Np
+       DO neq= 1,Neq_max
+          ro(neq,nb)  = 0.01*(nb+neq)*i
+       END DO
+    END DO
+
+    DO nb=1,Np
+       DO neq= 1,Neq_max
+          dro(neq,nb) = 0.05*(nb-neq)*i
+       END DO
+    END DO
+
+    DO n=1,Ng
+       DO nb=1,Np
+          basis(nb,n) = 0.05*(n+nb)*i
+       END DO
+    END DO
+
+  END SUBROUTINE init_element
+
+  !--------------------------------------------------------------!
+  SUBROUTINE loop_element_cpu_fortran(coeff,Neq_max,Np,Ng, &
+       &   ro_ptr,dro_ptr,basis_ptr) BIND(C) 
+    INTEGER(KIND=C_INT),VALUE                 :: Neq_max,Np,Ng
+    REAL(KIND=C_DOUBLE),VALUE                 :: coeff
+    TYPE(C_PTR)                               :: ro_ptr,dro_ptr,basis_ptr
+    !Local variables 
+    REAL,DIMENSION(:,:),POINTER               :: ro,dro,basis
+
+    CALL C_F_POINTER(ro_ptr,ro,[Neq_max,Np])
+    CALL C_F_POINTER(dro_ptr,dro,[Neq_max,Np])
+    CALL C_F_POINTER(basis_ptr,basis,[Np,Ng])
+  
+    CALL loop_element_cpu(ro,dro,basis,coeff,Neq_max,Ng,Np)
+
+  END SUBROUTINE loop_element_cpu_fortran
+
+  !--------------------------------------------------------------!
+  SUBROUTINE loop_element_cpu(ro,dro,basis,coeff,Neq_max,Ng,Np)
+    REAL,INTENT(IN)                           :: coeff
+    INTEGER,INTENT(IN)                        :: Neq_max,Ng,Np
+    REAL,DIMENSION(:,:),POINTER,INTENT(IN)    :: ro,basis
+    REAL,DIMENSION(:,:),POINTER,INTENT(INOUT) :: dro
+    !Local variables
+    REAL                                      :: coeff2,r
+    INTEGER                                   :: n,nb,neq
+
+    DO n=1,Ng
+       r = 0.
+       DO nb=1,Np
+          DO neq= 1,Neq_max
+             r = r + basis(nb,n) * ro(neq,nb)
+          ENDDO
+       ENDDO
+
+       coeff2 = r + coeff
+
+       DO nb=1,Np
+          DO neq = 1,Neq_max
+             dro(neq,nb) = coeff2 + dro(neq,nb)
+          ENDDO
+       ENDDO
+    ENDDO
+
+  END SUBROUTINE loop_element_cpu
+
+  !--------------------------------------------------------------!
+  SUBROUTINE copy_element_cpu_fortran(Neq_max,Np, &
+       &   ro_ptr,dro_ptr) BIND(C) 
+    INTEGER(KIND=C_INT),VALUE                 :: Neq_max,Np
+    TYPE(C_PTR)                               :: ro_ptr,dro_ptr
+    !Local variables 
+    REAL,DIMENSION(:,:),POINTER               :: ro,dro
+
+    CALL C_F_POINTER(ro_ptr,ro,[Neq_max,Np])
+    CALL C_F_POINTER(dro_ptr,dro,[Neq_max,Np])
+  
+    CALL copy_element_cpu(ro,dro)
+
+  END SUBROUTINE copy_element_cpu_fortran
+
+  !--------------------------------------------------------------!
+  SUBROUTINE copy_element_cpu(ro,dro)
+    REAL,DIMENSION(:,:),POINTER,INTENT(INOUT) :: ro
+    REAL,DIMENSION(:,:),POINTER,INTENT(IN)    :: dro
+
+    ro = ro + dro
+
+  END SUBROUTINE copy_element_cpu
+
+END MODULE mod_compute

+ 71 - 0
examples/fortran90/mod_interface.f90

@@ -0,0 +1,71 @@
+! StarPU --- Runtime system for heterogeneous multicore architectures.
+!
+! Copyright (C) 2015  ONERA
+! Copyright (C) 2015  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.
+
+MODULE mod_interface
+
+  INTERFACE
+     SUBROUTINE starpu_register_element_c(Neq,Np,Ng,ro,dro,basis,ro_h,dro_h,basis_h) BIND(C)
+       USE iso_c_binding
+       INTEGER(KIND=C_INT),VALUE             :: Neq,Np,Ng
+       REAL(KIND=C_DOUBLE),DIMENSION(Neq,Np) :: ro,dro
+       REAL(KIND=C_DOUBLE),DIMENSION(Np,Ng)  :: basis
+       TYPE(C_PTR), INTENT(OUT)              :: ro_h, dro_h, basis_h
+     END SUBROUTINE starpu_register_element_c
+  END INTERFACE
+
+  INTERFACE
+     SUBROUTINE starpu_unregister_element_c( &
+               ro_h,dro_h,basis_h) BIND(C)
+       USE iso_c_binding
+       TYPE(C_PTR), INTENT(IN)               :: ro_h, dro_h, basis_h
+     END SUBROUTINE starpu_unregister_element_c
+  END INTERFACE
+
+  INTERFACE
+     SUBROUTINE starpu_loop_element_task_c(coeff, &
+               ro_h,dro_h,basis_h) BIND(C)
+       USE iso_c_binding
+       REAL(KIND=C_DOUBLE),VALUE             :: coeff
+       TYPE(C_PTR), INTENT(IN)               :: ro_h, dro_h, basis_h
+     END SUBROUTINE starpu_loop_element_task_c
+  END INTERFACE
+
+  INTERFACE
+     SUBROUTINE starpu_copy_element_task_c( &
+               ro_h,dro_h) BIND(C)
+       USE iso_c_binding
+       TYPE(C_PTR), INTENT(IN)               :: ro_h, dro_h
+     END SUBROUTINE starpu_copy_element_task_c
+  END INTERFACE
+
+  INTERFACE
+     FUNCTION starpu_init_c() BIND(C)
+       USE iso_c_binding
+       INTEGER(KIND=C_INT)                   :: main_starpu_init_c
+     END FUNCTION starpu_init_c
+  END INTERFACE
+
+  INTERFACE starpu_task_wait_for_all_c
+     SUBROUTINE starpu_task_wait_for_all() BIND(C)
+     END SUBROUTINE starpu_task_wait_for_all
+  END INTERFACE
+
+  INTERFACE starpu_shutdown_c
+     SUBROUTINE starpu_shutdown() BIND(C)
+     END SUBROUTINE starpu_shutdown
+  END INTERFACE
+
+END MODULE mod_interface

+ 37 - 0
examples/fortran90/mod_types.f90

@@ -0,0 +1,37 @@
+! StarPU --- Runtime system for heterogeneous multicore architectures.
+!
+! Copyright (C) 2015  ONERA
+! Copyright (C) 2015  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.
+
+MODULE mod_types
+
+  USE iso_c_binding
+
+  TYPE type_numpar
+     REAL(KIND=C_DOUBLE)                        :: coeff
+     INTEGER(KIND=C_INT)                        :: Neq_max
+  END TYPE type_numpar
+
+  TYPE type_mesh_elt
+     INTEGER(KIND=C_INT)                        :: Ng, Np
+     REAL(KIND=C_DOUBLE),POINTER,DIMENSION(:,:) :: ro, dro
+     REAL(KIND=C_DOUBLE),POINTER,DIMENSION(:,:) :: basis
+     TYPE(C_PTR)                                :: ro_h, dro_h, basis_h
+  END TYPE type_mesh_elt
+
+  TYPE type_mesh
+     TYPE(type_mesh_elt), POINTER, DIMENSION(:) :: elt
+  END TYPE type_mesh
+
+END MODULE mod_types