Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
elpa
elpa
Commits
c3a093a6
Commit
c3a093a6
authored
Apr 16, 2019
by
Andreas Marek
Browse files
Optional arguments in C
parent
8fc1df8a
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
c3a093a6
...
...
@@ -48,7 +48,7 @@ static-build:
tags:
- avx
script:
- ./ci_test_scripts/run_ci_tests.sh -c " CFLAGS=\"-O3 -mavx\" FCFLAGS=\"-O3 -axAVX\" SCALAPACK_LDFLAGS=\"$MKL_INTEL_SCALAPACK_LDFLAGS_NO_MPI_NO_OMP\" SCALAPACK_FCFLAGS=\"$MKL_INTEL_SCALAPACK_FCFLAGS_NO_MPI_NO_OMP\" --with-mpi=no FC=ifort --enable-shared=no --enable-static=yes --disable-avx2 || { cat config.log; exit 1; } " -j 8 -t 2 -m 150 -n 50 -b 16 -s $SKIP_STEP -i $INTERACTIVE_RUN -S $SLURM
- ./ci_test_scripts/run_ci_tests.sh -c " CFLAGS=\"-O3 -mavx\" FCFLAGS=\"-O3 -axAVX\" SCALAPACK_LDFLAGS=\"$MKL_INTEL_SCALAPACK_LDFLAGS_NO_MPI_NO_OMP\" SCALAPACK_FCFLAGS=\"$MKL_INTEL_SCALAPACK_FCFLAGS_NO_MPI_NO_OMP\" --with-mpi=no FC=ifort --enable-shared=no --enable-static=yes --disable-avx2
--enable-optional-argument-in-C-API
|| { cat config.log; exit 1; } " -j 8 -t 2 -m 150 -n 50 -b 16 -s $SKIP_STEP -i $INTERACTIVE_RUN -S $SLURM
...
...
ci_test_scripts/generate_gitlab_ci_tests.py
View file @
c3a093a6
...
...
@@ -319,7 +319,7 @@ print(" tags:")
print
(
" - avx"
)
print
(
" script:"
)
print
(
" - ./ci_test_scripts/run_ci_tests.sh -c
\"
CFLAGS=
\\\"
-O3 -mavx
\\\"
FCFLAGS=
\\\"
-O3 -axAVX
\\\"
SCALAPACK_LDFLAGS=
\\\"
$MKL_INTEL_SCALAPACK_LDFLAGS_NO_MPI_NO_OMP
\\\"
\
SCALAPACK_FCFLAGS=
\\\"
$MKL_INTEL_SCALAPACK_FCFLAGS_NO_MPI_NO_OMP
\\\"
--with-mpi=no FC=ifort --enable-shared=no --enable-static=yes --disable-avx2 || { cat config.log; exit 1; }
\"
-j 8
\
SCALAPACK_FCFLAGS=
\\\"
$MKL_INTEL_SCALAPACK_FCFLAGS_NO_MPI_NO_OMP
\\\"
--with-mpi=no FC=ifort --enable-shared=no --enable-static=yes --disable-avx2
--enable-optional-argument-in-C-API
|| { cat config.log; exit 1; }
\"
-j 8
\
-t 2 -m 150 -n 50 -b 16 -s $SKIP_STEP -i $INTERACTIVE_RUN -S $SLURM "
)
print
(
"
\n\n
"
)
...
...
configure.ac
View file @
c3a093a6
...
...
@@ -68,6 +68,24 @@ if test x"${enable_legacy}" = x"yes"; then
AC_DEFINE([ENABLE_LEGACY], [1], [enable legacy interface])
fi
AC_MSG_CHECKING(whether in C interface the error argument should be optional)
AC_ARG_ENABLE([optional-argument-in-C-API],
AS_HELP_STRING([--enable-optional-argument-in-C-API],
[do not build C API with error argument as optional, default no]),
[
if test x"$enableval" = x"yes"; then
optional_c_error_argument=yes
else
optional_c_error_argument=no
fi
],
[optional_c_error_argument=no])
AC_MSG_RESULT([${optional_c_error_argument}])
AM_CONDITIONAL([OPTIONAL_C_ERROR_ARGUMENT],[test x"$enable_legacy" = x"yes"])
if test x"${optional_c_error_argument}" = x"yes"; then
AC_DEFINE([OPTIONAL_C_ERROR_ARGUMENT], [1], [enable error argument in C-API to be optional])
fi
# gnu-make fortran module dependencies
m4_include([fdep/fortran_dependencies.m4])
...
...
src/elpa_api.F90
View file @
c3a093a6
...
...
@@ -817,20 +817,42 @@ module elpa_api
api_version
=
api_version_set
end
function
#ifdef OPTIONAL_C_ERROR_ARGUMENT
!c> #define elpa_uninit(...) CONC(elpa_uninit, NARGS(__VA_ARGS__))(__VA_ARGS__)
#endif
!> \brief subroutine to uninit the ELPA library. Does nothing at the moment. Might do sth. later
!
!c> void elpa_uninit(int *error);
subroutine
elpa_uninit
(
error
)
bind
(
C
,
name
=
"elpa_uninit"
)
#ifdef OPTIONAL_C_ERROR_ARGUMENT
!c> void elpa_uninit1(int *error);
!c> void elpa_uninit0();
subroutine
elpa_uninit_c1
(
error
)
bind
(
C
,
name
=
"elpa_uninit1"
)
integer
(
kind
=
c_int
)
::
error
call
elpa_uninit
(
error
)
end
subroutine
subroutine
elpa_uninit_c0
()
bind
(
C
,
name
=
"elpa_uninit0"
)
call
elpa_uninit
()
end
subroutine
#else
subroutine
elpa_uninit_c
(
error
)
bind
(
C
,
name
=
"elpa_uninit"
)
integer
(
kind
=
c_int
)
::
error
call
elpa_uninit
(
error
)
end
subroutine
#endif
subroutine
elpa_uninit
(
error
)
#ifdef USE_FORTRAN2008
integer
,
optional
,
intent
(
out
)
::
error
integer
,
optional
,
intent
(
out
)
::
error
#else
integer
,
intent
(
out
)
::
error
integer
,
intent
(
out
)
::
error
#endif
#ifdef USE_FORTRAN2008
if
(
present
(
error
))
then
error
=
ELPA_OK
return
endif
#endif
if
(
present
(
error
))
error
=
ELPA_OK
end
subroutine
!> \brief helper function for error strings
!> Parameters
!> \param elpa_error integer: error code to querry
...
...
src/elpa_impl.F90
View file @
c3a093a6
...
...
@@ -215,30 +215,79 @@ module elpa_impl
endif
end
function
#ifdef OPTIONAL_C_ERROR_ARGUMENT
!c> #define elpa_allocate(...) CONC(elpa_allocate, NARGS(__VA_ARGS__))(__VA_ARGS__)
#endif
!c> /*! \brief C interface for the implementation of the elpa_allocate method
!c> *
!c> * \param none
!c> * \result elpa_t handle
!c> */
!c> elpa_t elpa_allocate(int *error);
function
elpa_impl_allocate_c
(
error
)
result
(
ptr
)
bind
(
C
,
name
=
"elpa_allocate"
)
integer
(
kind
=
c_int
)
::
error
type
(
c_ptr
)
::
ptr
#ifdef OPTIONAL_C_ERROR_ARGUMENT
!c> elpa_t elpa_allocate2(int *error);
!c> elpa_t elpa_allocate1();
function
elpa_impl_allocate_c1
()
result
(
ptr
)
bind
(
C
,
name
=
"elpa_allocate1"
)
type
(
c_ptr
)
::
ptr
type
(
elpa_impl_t
),
pointer
::
obj
obj
=>
elpa_impl_allocate
()
ptr
=
c_loc
(
obj
)
end
function
function
elpa_impl_allocate_c2
(
error
)
result
(
ptr
)
bind
(
C
,
name
=
"elpa_allocate2"
)
integer
(
kind
=
c_int
)
::
error
type
(
c_ptr
)
::
ptr
type
(
elpa_impl_t
),
pointer
::
obj
obj
=>
elpa_impl_allocate
(
error
)
ptr
=
c_loc
(
obj
)
end
function
#else
function
elpa_impl_allocate_c
(
error
)
result
(
ptr
)
bind
(
C
,
name
=
"elpa_allocate"
)
integer
(
kind
=
c_int
)
::
error
type
(
c_ptr
)
::
ptr
type
(
elpa_impl_t
),
pointer
::
obj
obj
=>
elpa_impl_allocate
(
error
)
ptr
=
c_loc
(
obj
)
end
function
#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__)
#endif
!c> /*! \brief C interface for the implementation of the elpa_deallocate method
!c> *
!c> * \param elpa_t handle of ELPA object to be deallocated
!c> * \param int* error code
!c> * \result void
!c> */
!c> void elpa_deallocate(elpa_t handle, int *error);
#ifdef OPTIONAL_C_ERROR_ARGUMENT
!c> void elpa_deallocate2(elpa_t handle, int *error);
!c> void elpa_deallocate1(elpa_t handle);
subroutine
elpa_impl_deallocate_c2
(
handle
,
error
)
bind
(
C
,
name
=
"elpa_deallocate2"
)
type
(
c_ptr
),
value
::
handle
type
(
elpa_impl_t
),
pointer
::
self
integer
(
kind
=
c_int
)
::
error
call
c_f_pointer
(
handle
,
self
)
call
self
%
destroy
(
error
)
deallocate
(
self
)
end
subroutine
subroutine
elpa_impl_deallocate_c1
(
handle
)
bind
(
C
,
name
=
"elpa_deallocate1"
)
type
(
c_ptr
),
value
::
handle
type
(
elpa_impl_t
),
pointer
::
self
call
c_f_pointer
(
handle
,
self
)
call
self
%
destroy
()
deallocate
(
self
)
end
subroutine
#else
subroutine
elpa_impl_deallocate_c
(
handle
,
error
)
bind
(
C
,
name
=
"elpa_deallocate"
)
type
(
c_ptr
),
value
::
handle
type
(
elpa_impl_t
),
pointer
::
self
...
...
@@ -249,6 +298,8 @@ module elpa_impl
deallocate
(
self
)
end
subroutine
#endif
!> \brief function to load all the parameters, which have been saved to a file
!> Parameters
!> \param self class(elpa_impl_t) the allocated ELPA object
...
...
@@ -387,13 +438,18 @@ 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__)
#endif
!c> /*! \brief C interface for the implementation of the elpa_autotune_deallocate method
!c> *
!c> * \param elpa_autotune_impl_t handle of ELPA autotune object to be deallocated
!c> * \result void
!c> */
!c> void elpa_autotune_deallocate(elpa_autotune_t handle, int *error);
subroutine
elpa_autotune_impl_deallocate_c
(
autotune_handle
)
bind
(
C
,
name
=
"elpa_autotune_deallocate"
)
#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);
subroutine
elpa_autotune_impl_deallocate_c1
(
autotune_handle
)
bind
(
C
,
name
=
"elpa_autotune_deallocate1"
)
type
(
c_ptr
),
value
::
autotune_handle
type
(
elpa_autotune_impl_t
),
pointer
::
self
...
...
@@ -402,7 +458,29 @@ module elpa_impl
call
self
%
destroy
()
deallocate
(
self
)
end
subroutine
subroutine
elpa_autotune_impl_deallocate_c2
(
autotune_handle
,
error
)
bind
(
C
,
name
=
"elpa_autotune_deallocate2"
)
type
(
c_ptr
),
value
::
autotune_handle
type
(
elpa_autotune_impl_t
),
pointer
::
self
integer
(
kind
=
c_int
)
::
error
call
c_f_pointer
(
autotune_handle
,
self
)
call
self
%
destroy
(
error
)
deallocate
(
self
)
end
subroutine
#else
subroutine
elpa_autotune_impl_deallocate
(
autotune_handle
,
error
)
bind
(
C
,
name
=
"elpa_autotune_deallocate"
)
type
(
c_ptr
),
value
::
autotune_handle
type
(
elpa_autotune_impl_t
),
pointer
::
self
integer
(
kind
=
c_int
)
::
error
call
c_f_pointer
(
autotune_handle
,
self
)
call
self
%
destroy
(
error
)
deallocate
(
self
)
end
subroutine
#endif
#endif /* ENABLE_AUTOTUNING */
!> \brief function to setup an ELPA object and to store the MPI communicators internally
!> Parameters
...
...
test/C/test_autotune.c
View file @
c3a093a6
...
...
@@ -174,7 +174,11 @@ int main(int argc, char** argv) {
exit
(
1
);
}
#ifdef OPTIONAL_C_ERROR_ARGUMENT
handle
=
elpa_allocate
();
#else
handle
=
elpa_allocate
(
&
error
);
#endif
assert_elpa_ok
(
error
);
/* Set parameters */
...
...
@@ -285,8 +289,13 @@ int main(int argc, char** argv) {
elpa_autotune_print_best
(
handle
,
autotune_handle
,
&
error
);
}
#ifdef OPTIONAL_C_ERROR_ARGUMENT
elpa_autotune_deallocate
(
autotune_handle
);
elpa_deallocate
(
handle
);
#else
elpa_autotune_deallocate
(
autotune_handle
,
&
error
);
elpa_deallocate
(
handle
,
&
error
);
#endif
elpa_uninit
(
&
error
);
if
(
myid
==
0
)
{
...
...
test/C/test_multiple_objs.c
View file @
c3a093a6
...
...
@@ -230,7 +230,11 @@ int main(int argc, char** argv) {
MPI_Barrier
(
MPI_COMM_WORLD
);
#endif
#ifdef OPTIONAL_C_ERROR_ARGUMENT
elpa_handle_2
=
elpa_allocate
();
#else
elpa_handle_2
=
elpa_allocate
(
&
error
);
#endif
assert_elpa_ok
(
error
);
set_basic_parameters
(
&
elpa_handle_2
,
na
,
nev
,
na_rows
,
na_cols
,
nblk
,
my_prow
,
my_pcol
);
...
...
@@ -341,7 +345,11 @@ int main(int argc, char** argv) {
elpa_autotune_deallocate
(
autotune_handle
,
&
error
);
elpa_deallocate
(
elpa_handle_1
,
&
error
);
#ifdef OPTIONAL_C_ERROR_ARGUMENT
elpa_deallocate
(
elpa_handle_2
);
#else
elpa_deallocate
(
elpa_handle_2
,
&
error
);
#endif
elpa_uninit
(
&
error
);
if
(
myid
==
0
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment