Commit 07576e5f authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add logic to change exchanger.

parent 569fbac8
......@@ -70,6 +70,30 @@ Xt_config xt_config_new(void);
*/
void xt_config_delete(Xt_config config);
enum Xt_exchangers {
xt_exchanger_irecv_send,
xt_exchanger_irecv_isend,
xt_exchanger_irecv_isend_packed,
xt_exchanger_mix_isend_irecv,
xt_exchanger_neigh_alltoall,
};
/**
* set exchanger to use when the \a config object is passed to constructors
* @param[in,out] config configuration object to modify
* @param method an entry from enum Xt_exchangers to signify the
* desired exchanger for data transfers
*/
void xt_config_set_exchange_method(Xt_config config, int method);
/**
* get exchanger used when the \a config object is passed to constructors
* @param[in] config configuration object to modify
* @return an entry from enum Xt_exchangers representing the method of
* data transfer used
*/
int xt_config_get_exchange_method(Xt_config config);
#endif
/*
......
......@@ -52,10 +52,12 @@
#include <xt/xt_config.h>
#include "xt_config_internal.h"
#include "xt_exchanger_irecv_send.h"
#include "xt_exchanger_irecv_isend.h"
#include "xt_exchanger_mix_isend_irecv.h"
#include "xt_exchanger_irecv_isend_packed.h"
#include "xt_exchanger_neigh_alltoall.h"
#include "core/core.h"
#include "core/ppm_xfuncs.h"
const struct Xt_config_ xt_default_config = {
......@@ -74,6 +76,52 @@ void xt_config_delete(Xt_config config)
free(config);
}
static struct {
Xt_exchanger_new f;
int code;
} exchanger_table[] = {
{ xt_exchanger_irecv_send_new, xt_exchanger_irecv_send },
{ xt_exchanger_irecv_isend_new, xt_exchanger_irecv_isend },
{ xt_exchanger_irecv_isend_packed_new, xt_exchanger_irecv_isend_packed },
{ xt_exchanger_mix_isend_irecv_new, xt_exchanger_mix_isend_irecv },
{ xt_exchanger_neigh_alltoall_new, xt_exchanger_neigh_alltoall },
};
enum {
num_exchanger = sizeof (exchanger_table) / sizeof (exchanger_table[0]),
};
int xt_config_get_exchange_method(Xt_config config)
{
Xt_exchanger_new exchanger_new = config->exchanger_new;
for (size_t i = 0; i < num_exchanger; ++i)
if (exchanger_table[i].f == exchanger_new)
return (int)i;
static const char fmt[]
= "error: unexpected exchanger function (%p)!\n";
char buf[sizeof (fmt) + 9];
sprintf(buf, fmt, (void *)exchanger_new);
Xt_abort(Xt_default_comm, buf, "xt_config.c", __LINE__);
}
void xt_config_set_exchange_method(Xt_config config, int method)
{
for (size_t i = 0; i < num_exchanger; ++i)
if (exchanger_table[i].code == method) {
config->exchanger_new = exchanger_table[i].f;
return;
}
static const char fmt[]
= "error: user-requested exchanger code (%d) does not exist!\n";
char buf[sizeof (fmt) + 9];
sprintf(buf, fmt, method);
Xt_abort(Xt_default_comm, buf, "xt_config.c", __LINE__);
}
/*
* Local Variables:
......
......@@ -46,7 +46,7 @@
! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!
MODULE xt_config_f
USE, INTRINSIC :: ISO_C_BINDING, ONLY: c_ptr, c_null_ptr
USE, INTRINSIC :: ISO_C_BINDING, ONLY: c_ptr, c_null_ptr, c_int
IMPLICIT NONE
PRIVATE
! note: this type must not be extended to contain any other
......@@ -59,6 +59,14 @@ MODULE xt_config_f
TYPE(c_ptr) :: cptr = c_null_ptr
END TYPE xt_config
PUBLIC :: xt_config_new, xt_config_delete
PUBLIC :: xt_config_get_exchange_method, xt_config_set_exchange_method
INTEGER, PUBLIC, PARAMETER :: &
xt_exchanger_irecv_send = 0, &
xt_exchanger_irecv_isend = 1, &
xt_exchanger_irecv_isend_packed = 2, &
xt_exchanger_mix_isend_irecv = 3, &
xt_exchanger_neigh_alltoall = 4
CONTAINS
FUNCTION xt_config_new() RESULT(config)
......@@ -86,6 +94,36 @@ CONTAINS
CALL xt_config_delete_c(config%cptr)
END SUBROUTINE xt_config_delete
SUBROUTINE xt_config_set_exchange_method(config, method)
TYPE(xt_config), INTENT(inout) :: config
INTEGER, INTENT(in) :: method
INTEGER(c_int) :: method_c
INTERFACE
SUBROUTINE xt_config_set_exchange_method_c(config, method) &
BIND(c, name='xt_config_set_exchange_method')
IMPORT :: c_int, c_ptr
TYPE(c_ptr), VALUE :: config
INTEGER(c_int), VALUE :: method
END SUBROUTINE xt_config_set_exchange_method_c
END INTERFACE
method_c = INT(method, c_int)
CALL xt_config_set_exchange_method_c(config%cptr, method_c)
END SUBROUTINE xt_config_set_exchange_method
FUNCTION xt_config_get_exchange_method(config) RESULT(method)
TYPE(xt_config), INTENT(in) :: config
INTEGER :: method
INTERFACE
FUNCTION xt_config_get_exchange_method_c(config) RESULT(method) &
BIND(c, name='xt_config_get_exchange_method')
IMPORT :: c_int, c_ptr
TYPE(c_ptr), VALUE :: config
INTEGER(c_int) :: method
END FUNCTION xt_config_get_exchange_method_c
END INTERFACE
method = INT(xt_config_get_exchange_method_c(config%cptr))
END FUNCTION xt_config_get_exchange_method
END MODULE xt_config_f
!
! Local Variables:
......
......@@ -55,7 +55,11 @@ MODULE yaxt
char, xt_finalize, xt_initialized, xt_finalized, xt_slice_c_loc, &
xt_pos_ext, OPERATOR(/=), OPERATOR(==), &
xt_set_abort_handler => set_abort_handler, xt_restore_default_abort_hndl
USE xt_config_f, ONLY: xt_config, xt_config_new, xt_config_delete
USE xt_config_f, ONLY: xt_config, xt_config_new, xt_config_delete, &
xt_config_get_exchange_method, xt_config_set_exchange_method, &
xt_exchanger_irecv_send, xt_exchanger_irecv_isend, &
xt_exchanger_irecv_isend_packed, xt_exchanger_mix_isend_irecv, &
xt_exchanger_neigh_alltoall
USE xt_sort, ONLY: xt_sort_int, xt_sort_index, xt_sort_idxpos, &
xt_sort_permutation
USE xt_idxlist_abstract, ONLY: &
......@@ -173,7 +177,11 @@ MODULE yaxt
xt_request_wait, xt_request_test, xt_redist_a_exchange1, &
xt_redist_a_exchange
PUBLIC :: xt_config, xt_config_new, xt_config_delete
PUBLIC :: xt_config, xt_config_new, xt_config_delete, &
xt_config_get_exchange_method, xt_config_set_exchange_method, &
xt_exchanger_irecv_send, xt_exchanger_irecv_isend, &
xt_exchanger_irecv_isend_packed, xt_exchanger_mix_isend_irecv, &
xt_exchanger_neigh_alltoall
INTERFACE OPERATOR(==)
MODULE PROCEDURE xt_bounds_eq
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment