diff --git a/Makefile.am b/Makefile.am index 83dad159a7e2b52ef5876c3705c5605febf399d2..24699e01a99f40c6385926f0abcec47f18239833 100644 --- a/Makefile.am +++ b/Makefile.am @@ -455,6 +455,7 @@ nobase_nodist_elpa_include_HEADERS = \ elpa/elpa_version.h \ elpa/elpa_constants.h \ elpa/elpa_generated.h \ + elpa/elpa_generated_c_api.h \ elpa/elpa_generated_legacy.h dist_man_MANS = \ @@ -686,7 +687,8 @@ test_python.sh: include doxygen.am CLEANFILES = \ - elpa-generated.h \ + elpa_generated.h \ + elpa_generated_c_api.h \ elpa1_test* \ elpa2_test*\ elpa2_real* \ @@ -718,16 +720,14 @@ clean-local: -rm -rf $(generated_headers) distclean-local: + -rm -rf ./m4 + -rm -rf ./src + -rm -rf ./test + -rm -rf ./modules + -rm -rf .fortran_dependencies -rm config-f90.h - -rm -rf ./src/elpa2/kernels/.deps - -rm -rf ./src/.deps -rm -rf ./test/.deps - -rmdir ./src/elpa2/kernels/ - -rmdir ./src - -rmdir ./test - -rmdir ./m4 - -rmdir modules/ - -rmdir .fortran_dependencies/ + -rm -rf elpa/elpa_generated_c_api.h EXTRA_DIST = \ elpa.spec \ diff --git a/configure.ac b/configure.ac index add804a607ddbe6b661bf37f31aa2d90e18a7064..113d96ff3a8b48189d8a6028a6688983431b1157 100644 --- a/configure.ac +++ b/configure.ac @@ -1473,5 +1473,11 @@ if test x"$enable_kcomputer" = x"yes" ; then echo "call: make -f ../generated_headers.am generated-headers top_srcdir=.." echo "BEFORE triggering the build with make!" else + if test x"$optional_c_error_argument" = x"yes" ; then + echo "#define OPTIONAL_C_ERROR_ARGUMENT" > elpa/elpa_generated_c_api.h + else + echo "#undef OPTIONAL_C_ERROR_ARGUMENT" > elpa/elpa_generated_c_api.h + fi make -f $srcdir/generated_headers.am generated-headers top_srcdir="$srcdir" CPP="$CPP" fi + diff --git a/elpa/elpa.h b/elpa/elpa.h index 4b9682e31432ea9c89502bbc1f04c59e1a36d5b8..85fc68422e328ec82f21f1abd95a89059792f4fa 100644 --- a/elpa/elpa.h +++ b/elpa/elpa.h @@ -14,6 +14,7 @@ typedef struct elpa_autotune_struct *elpa_autotune_t; #include +#include #include #include diff --git a/generated_headers.am b/generated_headers.am index 1d1bcc5afb065dbb790dcdd4619939f116a2ef55..caf7741664bbb34bc3665a031c4c913582e2fa37 100644 --- a/generated_headers.am +++ b/generated_headers.am @@ -22,6 +22,22 @@ elpa/elpa_generated.h: $(top_srcdir)/src/elpa_impl.F90 \ $(top_srcdir)/src/elpa_api.F90 | elpa @rm -f $@ $(call extract_interface,!c>) + $(call extract_interface,!c_o>) + $(call extract_interface,!c_no>) + +#if OPTIONAL_C_ERROR_ARGUMENT +# +#elpa/elpa_generated.h: $(top_srcdir)/src/elpa_impl.F90 \ +# $(top_srcdir)/src/elpa_impl_math_template.F90 \ +# $(top_srcdir)/src/elpa_api.F90 | elpa +# $(call extract_interface,!c_o>) +# +#else +#elpa/elpa_generated.h: $(top_srcdir)/src/elpa_impl.F90 \ +# $(top_srcdir)/src/elpa_impl_math_template.F90 \ +# $(top_srcdir)/src/elpa_api.F90 | elpa +# $(call extract_interface,!c_no>) +#endif generated_headers += elpa/elpa_generated_legacy.h elpa/elpa_generated_legacy.h: $(top_srcdir)/src/elpa_driver/legacy_interface/elpa_driver_c_interface.F90 \ diff --git a/src/elpa_api.F90 b/src/elpa_api.F90 index 53bd22b7b343a68e1dc151db809e77a65feee3b6..df75c87b0fb49d8467b9572c8d41404786ddd61f 100644 --- a/src/elpa_api.F90 +++ b/src/elpa_api.F90 @@ -818,13 +818,17 @@ module elpa_api end function #ifdef OPTIONAL_C_ERROR_ARGUMENT - !c> #define elpa_uninit(...) CONC(elpa_uninit, NARGS(__VA_ARGS__))(__VA_ARGS__) + !c_o> #ifdef OPTIONAL_C_ERROR_ARGUMENT + !c_o> #define elpa_uninit(...) CONC(elpa_uninit, NARGS(__VA_ARGS__))(__VA_ARGS__) + !c_o> #endif #endif !> \brief subroutine to uninit the ELPA library. Does nothing at the moment. Might do sth. later ! #ifdef OPTIONAL_C_ERROR_ARGUMENT - !c> void elpa_uninit1(int *error); - !c> void elpa_uninit0(); + !c_o> #ifdef OPTIONAL_C_ERROR_ARGUMENT + !c_o> void elpa_uninit1(int *error); + !c_o> void elpa_uninit0(); + !c_o> #endif subroutine elpa_uninit_c1(error) bind(C, name="elpa_uninit1") integer(kind=c_int) :: error call elpa_uninit(error) @@ -834,6 +838,9 @@ module elpa_api call elpa_uninit() end subroutine #else + !c_no> #ifndef OPTIONAL_C_ERROR_ARGUMENT + !c_no> void elpa_uninit(int *error); + !c_no> #endif subroutine elpa_uninit_c(error) bind(C, name="elpa_uninit") integer(kind=c_int) :: error call elpa_uninit(error) diff --git a/src/elpa_impl.F90 b/src/elpa_impl.F90 index 8f28b35636d4b53bdceb2e13ba825856730e55b2..092bda40e6aebfd6db5e6db0f43822a247949edf 100644 --- a/src/elpa_impl.F90 +++ b/src/elpa_impl.F90 @@ -216,7 +216,9 @@ module elpa_impl end function #ifdef OPTIONAL_C_ERROR_ARGUMENT - !c> #define elpa_allocate(...) CONC(elpa_allocate, NARGS(__VA_ARGS__))(__VA_ARGS__) + !c_o> #ifdef OPTIONAL_C_ERROR_ARGUMENT + !c_o> #define elpa_allocate(...) CONC(elpa_allocate, NARGS(__VA_ARGS__))(__VA_ARGS__) + !c_o> #endif #endif !c> /*! \brief C interface for the implementation of the elpa_allocate method !c> * @@ -224,8 +226,10 @@ module elpa_impl !c> * \result elpa_t handle !c> */ #ifdef OPTIONAL_C_ERROR_ARGUMENT - !c> elpa_t elpa_allocate2(int *error); - !c> elpa_t elpa_allocate1(); + !c_o> #ifdef OPTIONAL_C_ERROR_ARGUMENT + !c_o> elpa_t elpa_allocate2(int *error); + !c_o> elpa_t elpa_allocate1(); + !c_o> #endif function elpa_impl_allocate_c1() result(ptr) bind(C, name="elpa_allocate1") type(c_ptr) :: ptr type(elpa_impl_t), pointer :: obj @@ -243,6 +247,9 @@ module elpa_impl ptr = c_loc(obj) end function #else + !c_no> #ifndef OPTIONAL_C_ERROR_ARGUMENT + !c_no> elpa_t elpa_allocate(int *error); + !c_no> #endif function elpa_impl_allocate_c(error) result(ptr) bind(C, name="elpa_allocate") integer(kind=c_int) :: error type(c_ptr) :: ptr @@ -254,11 +261,13 @@ module elpa_impl #endif #ifdef OPTIONAL_C_ERROR_ARGUMENT - !c> #define NARGS(...) NARGS_(__VA_ARGS__, 5, 4, 3, 2, 1, 0) - !c> #define NARGS_(_5, _4, _3, _2, _1, N, ...) N - !c> #define CONC(A, B) CONC_(A, B) - !c> #define CONC_(A, B) A##B - !c> #define elpa_deallocate(...) CONC(elpa_deallocate, NARGS(__VA_ARGS__))(__VA_ARGS__) + !c_o> #ifdef OPTIONAL_C_ERROR_ARGUMENT + !c_o> #define NARGS(...) NARGS_(__VA_ARGS__, 5, 4, 3, 2, 1, 0) + !c_o> #define NARGS_(_5, _4, _3, _2, _1, N, ...) N + !c_o> #define CONC(A, B) CONC_(A, B) + !c_o> #define CONC_(A, B) A##B + !c_o> #define elpa_deallocate(...) CONC(elpa_deallocate, NARGS(__VA_ARGS__))(__VA_ARGS__) + !c_o> #endif #endif !c> /*! \brief C interface for the implementation of the elpa_deallocate method !c> * @@ -267,8 +276,10 @@ module elpa_impl !c> * \result void !c> */ #ifdef OPTIONAL_C_ERROR_ARGUMENT - !c> void elpa_deallocate2(elpa_t handle, int *error); - !c> void elpa_deallocate1(elpa_t handle); + !c_o> #ifdef OPTIONAL_C_ERROR_ARGUMENT + !c_o> void elpa_deallocate2(elpa_t handle, int *error); + !c_o> void elpa_deallocate1(elpa_t handle); + !c_o> #endif subroutine elpa_impl_deallocate_c2(handle, error) bind(C, name="elpa_deallocate2") type(c_ptr), value :: handle type(elpa_impl_t), pointer :: self @@ -288,6 +299,9 @@ module elpa_impl deallocate(self) end subroutine #else + !c_no> #ifndef OPTIONAL_C_ERROR_ARGUMENT + !c_no> void elpa_deallocate(elpa_t handle, int *error); + !c_no> #endif subroutine elpa_impl_deallocate_c(handle, error) bind(C, name="elpa_deallocate") type(c_ptr), value :: handle type(elpa_impl_t), pointer :: self @@ -439,7 +453,9 @@ module elpa_impl #ifdef ENABLE_AUTOTUNING #ifdef OPTIONAL_C_ERROR_ARGUMENT - !c> #define elpa_autotune_deallocate(...) CONC(elpa_autotune_deallocate, NARGS(__VA_ARGS__))(__VA_ARGS__) + !c_o> #ifdef OPTIONAL_C_ERROR_ARGUMENT + !c_o> #define elpa_autotune_deallocate(...) CONC(elpa_autotune_deallocate, NARGS(__VA_ARGS__))(__VA_ARGS__) + !c_o> #endif #endif !c> /*! \brief C interface for the implementation of the elpa_autotune_deallocate method !c> * @@ -447,8 +463,10 @@ module elpa_impl !c> * \result void !c> */ #ifdef OPTIONAL_C_ERROR_ARGUMENT - !c> void elpa_autotune_deallocate2(elpa_autotune_t handle, int *error); - !c> void elpa_autotune_deallocate1(elpa_autotune_t handle); + !c_o> #ifdef OPTIONAL_C_ERROR_ARGUMENT + !c_o> void elpa_autotune_deallocate2(elpa_autotune_t handle, int *error); + !c_o> void elpa_autotune_deallocate1(elpa_autotune_t handle); + !c_o> #endif subroutine elpa_autotune_impl_deallocate_c1( autotune_handle) bind(C, name="elpa_autotune_deallocate1") type(c_ptr), value :: autotune_handle @@ -469,6 +487,9 @@ module elpa_impl deallocate(self) end subroutine #else + !c_no> #ifndef OPTIONAL_C_ERROR_ARGUMENT + !c_no> void elpa_autotune_deallocate(elpa_autotune_t handle, int *error); + !c_no> #endif subroutine elpa_autotune_impl_deallocate( autotune_handle, error) bind(C, name="elpa_autotune_deallocate") type(c_ptr), value :: autotune_handle diff --git a/test/C/test.c b/test/C/test.c index 25051b99fab5f2ae675bd749b6a02e65053136ba..8b57ba9a7545c328d3bc3774bf2f7e0bddc9e20d 100644 --- a/test/C/test.c +++ b/test/C/test.c @@ -199,7 +199,7 @@ int main(int argc, char** argv) { } handle = elpa_allocate(&error); - assert_elpa_ok(error); + //assert_elpa_ok(error); /* Set parameters */ elpa_set(handle, "na", na, &error); diff --git a/test/C/test_autotune.c b/test/C/test_autotune.c index e02636b5f7bd5aa23eea9cb0f224cd1c598d0c6c..359a79e4e9a1c4ddfaa288411def23748c0a0907 100644 --- a/test/C/test_autotune.c +++ b/test/C/test_autotune.c @@ -180,6 +180,7 @@ int main(int argc, char** argv) { handle = elpa_allocate(&error); #endif assert_elpa_ok(error); +#endif /* Set parameters */ elpa_set(handle, "na", na, &error); diff --git a/test/C/test_multiple_objs.c b/test/C/test_multiple_objs.c index 666f196a226722399d444e064a6ed78995a37bc0..e917e70156472fd3388b30a60af8724c96f04d9a 100644 --- a/test/C/test_multiple_objs.c +++ b/test/C/test_multiple_objs.c @@ -236,6 +236,7 @@ int main(int argc, char** argv) { elpa_handle_2 = elpa_allocate(&error); #endif assert_elpa_ok(error); +#endif set_basic_parameters(&elpa_handle_2, na, nev, na_rows, na_cols, nblk, my_prow, my_pcol); /* Setup */