Commit de802f5d authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add configuration object.

* This facilitates per-call selection of the underlying exchanger.
parent ede135a4
......@@ -41,6 +41,7 @@ lib_LTLIBRARIES = libyaxt_c.la libyaxt.la
# which they can be combined in yaxt.h.
libyaxt_c_la_SOURCES = \
xt/xt_core.h \
xt/xt_config.h \
xt/xt_handles.h \
xt/sort_common.h \
xt/mergesort.h \
......@@ -70,6 +71,8 @@ libyaxt_c_la_SOURCES = \
xt/xt_request_msgs_packed.h \
xt_arithmetic_util.h \
xt_arithmetic_long.h \
xt_config_internal.h \
xt_config.c \
xt_cover.h \
xt_cover.c \
xt_handles.c \
......
/**
* @file xt_config.h
* @brief opaque configuration object for settings where the default
* needs to be overridden
*
* @copyright Copyright (C) 2020 Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*
* @author Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*/
/*
* Maintainer: Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*
* URL: https://doc.redmine.dkrz.de/yaxt/html/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the DKRZ GmbH nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef XT_CONFIG_H
#define XT_CONFIG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
typedef struct Xt_config_ *Xt_config;
/**
* constructor for configuration object
*
* @return returns a configuration object where every setting is set
* to the corresponding default.
*/
Xt_config xt_config_new(void);
/**
* destructor of configuration objects
*
* @param[in,out] config configuration object to destroy
*/
void xt_config_delete(Xt_config config);
#endif
/*
* Local Variables:
* c-basic-offset: 2
* coding: utf-8
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
......@@ -51,6 +51,7 @@
#include <config.h>
#endif
#include "xt/xt_config.h"
#include "xt/xt_redist.h"
/** \example test_redist_collection.c
......@@ -64,7 +65,7 @@
/**
* constructor for a redistribution collection that is comprised
* of multiple other redistributions
* of multiple other redistributions with default settings
* @param[in] redists redistributions
* @param[in] num_redists number of redistributions
* @param[in] cache_size number of cached datatypes required for
......@@ -82,6 +83,28 @@
Xt_redist xt_redist_collection_new(Xt_redist * redists, int num_redists,
int cache_size, MPI_Comm comm);
/**
* constructor for a redistribution collection that is comprised
* of multiple other redistributions with custom settings
* @param[in] redists redistributions
* @param[in] num_redists number of redistributions
* @param[in] cache_size number of cached datatypes required for
* different input array displacements \n
* n = -1 => default cache size \n
* n = 0 => no cache \n
* n > 0 => cache size = n
* @param[in] comm MPI communicator
* @param[in] config custom configuration object
*
* @remarks all redistributions need to be based on the same
* MPI communicator
* @par See Also
* \ref correct_addresses
*/
Xt_redist xt_redist_collection_custom_new(Xt_redist * redists, int num_redists,
int cache_size, MPI_Comm comm,
Xt_config config);
#endif // XT_REDIST_COLLECTION_H
/*
......
......@@ -51,6 +51,7 @@
#include <config.h>
#endif
#include "xt/xt_config.h"
#include "xt/xt_redist.h"
/** \example test_redist_collection_static.c
......@@ -64,7 +65,7 @@
/**
* constructor for a redistribution collection that is comprised
* of multiple other redistributions
* of multiple other redistributions with default settings
* @param[in] redists redistributions
* @param[in] num_redists number of redistributions
* @param[in] src_displacements array of displacements of the source
......@@ -84,6 +85,30 @@ xt_redist_collection_static_new(Xt_redist * redists, int num_redists,
const MPI_Aint dst_displacements[num_redists],
MPI_Comm comm);
/**
* constructor for a redistribution collection that is comprised
* of multiple other redistributions with custom settings
* @param[in] redists redistributions
* @param[in] num_redists number of redistributions
* @param[in] src_displacements array of displacements of the source
* input arrays for the exchange
* @param[in] dst_displacements array of displacements of the destination
* input arrays for the exchange
* @param[in] comm MPI communicator
* @param[in] config configuration object for customizable settings
*
* @remarks all redistributions need to be based on the same
* MPI communicator
* @par See Also
* \ref correct_addresses
*/
Xt_redist
xt_redist_collection_static_custom_new(
Xt_redist *redists, int num_redists,
const MPI_Aint src_displacements[num_redists],
const MPI_Aint dst_displacements[num_redists],
MPI_Comm comm, Xt_config config);
#endif // XT_REDIST_COLLECTION_STATIC_H
/*
......
......@@ -56,6 +56,7 @@
#include "xt/xt_core.h"
#include "xt/xt_xmap.h"
#include "xt/xt_redist.h"
#include "xt/xt_config.h"
/** \example test_redist_p2p.c
*/
......@@ -64,7 +65,7 @@
/**
* constructor for a redistribution using point to point
* communication for the exchange
* communication for the exchange. Uses default settings.
* @param[in] xmap exchange map
* @param[in] datatype MPI datatype of single element
* in the data to be exchanged
......@@ -73,7 +74,18 @@ Xt_redist xt_redist_p2p_new(Xt_xmap xmap, MPI_Datatype datatype);
/**
* constructor for a redistribution using point to point
* communication for the exchange
* communication for the exchange. Uses custom settings.
* @param[in] xmap exchange map
* @param[in] datatype MPI datatype of single element
* in the data to be exchanged
* @param[in] config configuration object for custom settings
*/
Xt_redist
xt_redist_p2p_custom_new(Xt_xmap xmap, MPI_Datatype datatype, Xt_config config);
/**
* constructor for a redistribution using point to point
* communication for the exchange. Uses default settings.
* @param[in] xmap exchange map
* @param[in] src_offsets array containing for all elements in
* the source index list passed to the
......@@ -93,7 +105,30 @@ Xt_redist xt_redist_p2p_off_new(Xt_xmap xmap, const int *src_offsets,
/**
* constructor for a redistribution using point to point
* communication for the exchange
* communication for the exchange. Uses custom settings.
* @param[in] xmap exchange map
* @param[in] src_offsets array containing for all elements in
* the source index list passed to the
* exchange map the position of the respective
* element in the input array passed to the
* exchange routine
* @param[in] dst_offsets array containing for all elements in
* the destination index list passed to the
* exchange map the position of the respective
* element in the output array passed to the
* exchange routine
* @param[in] datatype MPI datatype of single element
* in the data to be exchanged
* @param[in] config configuration object for custom settings
*/
Xt_redist
xt_redist_p2p_off_custom_new(Xt_xmap xmap, const int *src_offsets,
const int *dst_offsets, MPI_Datatype datatype,
Xt_config config);
/**
* constructor for a redistribution using point to point
* communication for the exchange. Uses default settings.
* @param[in] xmap exchange map
* @param[in] num_src_ext number of source extents
* @param[in] src_extents array of extents describing offsets for every
......@@ -112,6 +147,30 @@ Xt_redist xt_redist_p2p_ext_new(Xt_xmap xmap,
const struct Xt_offset_ext dst_extents[],
MPI_Datatype datatype);
/**
* constructor for a redistribution using point to point
* communication for the exchange. Uses custom settings.
* @param[in] xmap exchange map
* @param[in] num_src_ext number of source extents
* @param[in] src_extents array of extents describing offsets for every
* element of the index lists composing the xmap,
* i.e. { 10, 5, 1 } denotes 5 offsets,
* namely 10, 11, 12, 13, 14
* @param[in] num_dst_ext number of destination extents
* @param[in] dst_extents array of extents analogous to src_extents
* @param[in] datatype MPI datatype of single element
* in the data to be exchanged
* @param[in] config configuration object for custom settings
*/
Xt_redist
xt_redist_p2p_ext_custom_new(Xt_xmap xmap,
int num_src_ext,
const struct Xt_offset_ext src_extents[],
int num_dst_ext,
const struct Xt_offset_ext dst_extents[],
MPI_Datatype datatype,
Xt_config config);
/**
* constructor for a redistribution using point to point
* communication for the exchange, special case: elements (which
......@@ -131,7 +190,7 @@ Xt_redist xt_redist_p2p_ext_new(Xt_xmap xmap,
* @param[in] dst_block_num number of dst blocks
* @param[in] datatype MPI datatype of a single element in data space,
* all elements have the same
* \remarks NULL offsets arguments mean: use zero based prefix sum of block sizes as
* @remarks NULL offsets arguments mean: use zero based prefix sum of block sizes as
* effective offsets
*/
Xt_redist xt_redist_p2p_blocks_off_new(Xt_xmap xmap,
......@@ -143,6 +202,40 @@ Xt_redist xt_redist_p2p_blocks_off_new(Xt_xmap xmap,
int dst_block_num,
MPI_Datatype datatype);
/**
* constructor for a redistribution using point to point
* communication for the exchange, special case: elements (which
* correspond to each idxlist element) are blocks of variable length
* with corresponding offsets, therefore src_block_num and
* dst_block_num must match the lengths of the src/dst index lists
* used for the construction of xmap. Uses custom settings.
*
* @param[in] xmap exchange map
* @param[in] src_block_offsets array containing for all source index space positions
* of xmap the offsets for blocks in data space
* @param[in] src_block_sizes source block lengths in unit of elements
* @param[in] src_block_num number of src blocks
* @param[in] dst_block_offsets array containing for all destination index space positions
* of xmap the offsets for blocks in data space
* @param[in] dst_block_sizes destination block lengths in unit of elements
* @param[in] dst_block_num number of dst blocks
* @param[in] datatype MPI datatype of a single element in data space,
* all elements have the same
* @param[in] config configuration object for custom settings
* @remarks NULL offsets arguments mean: use zero based prefix sum of block sizes as
* effective offsets
*/
Xt_redist
xt_redist_p2p_blocks_off_custom_new(Xt_xmap xmap,
const int *src_block_offsets,
const int *src_block_sizes,
int src_block_num,
const int *dst_block_offsets,
const int *dst_block_sizes,
int dst_block_num,
MPI_Datatype datatype,
Xt_config config);
/**
* constructor for a redistribution using point to point
* communication for the exchange, special case: blocks without
......@@ -154,7 +247,7 @@ Xt_redist xt_redist_p2p_blocks_off_new(Xt_xmap xmap,
* @param[in] dst_block_num number of dst blocks
* @param[in] datatype MPI datatype of a single element in data space,
* all elements have the same
* \remarks calls \ref xt_redist_p2p_blocks_off_new with NULL offsets
* @remarks calls \ref xt_redist_p2p_blocks_off_new with NULL offsets
*/
Xt_redist xt_redist_p2p_blocks_new(Xt_xmap xmap,
const int *src_block_sizes,
......@@ -163,6 +256,29 @@ Xt_redist xt_redist_p2p_blocks_new(Xt_xmap xmap,
int dst_block_num,
MPI_Datatype datatype);
/**
* constructor for a redistribution using point to point
* communication for the exchange, special case: blocks without
* explicit offsets
* @param[in] xmap exchange map
* @param[in] src_block_sizes source block lengths in unit of elements
* @param[in] src_block_num number of src blocks
* @param[in] dst_block_sizes destination block lengths in unit of elements
* @param[in] dst_block_num number of dst blocks
* @param[in] datatype MPI datatype of a single element in data space,
* all elements have the same
* @param[in] config configuration object for custom settings
* @remarks calls \ref xt_redist_p2p_blocks_off_new with NULL offsets
*/
Xt_redist
xt_redist_p2p_blocks_custom_new(Xt_xmap xmap,
const int *src_block_sizes,
int src_block_num,
const int *dst_block_sizes,
int dst_block_num,
MPI_Datatype datatype,
Xt_config config);
#endif // XT_REDIST_P2P_H
/*
......
......@@ -52,6 +52,7 @@
#endif
#include "xt/xt_redist.h"
#include "xt/xt_config.h"
/** \example test_redist_repeat.c
*/
......@@ -64,7 +65,7 @@
/**
* constructor for a redistribution that has a repetitive pattern, which
* is described by the given redistribution
* is described by the given redistribution with default settings
* @param[in] redist redistribution
* @param[in] src_extent extent that scales the given displacements
* for the source data
......@@ -81,7 +82,47 @@ Xt_redist xt_redist_repeat_new(Xt_redist redist, MPI_Aint src_extent,
/**
* constructor for a redistribution that has a repetitive pattern, which
* is described by the given redistribution
* is described by the given redistribution with custom settings
* @param[in] redist redistribution
* @param[in] src_extent extent that scales the given displacements
* for the source data
* @param[in] dst_extent extent that scales the given displacements
* for the destination data
* @param[in] num_repetitions number of repetitions of the given
* redistribution
* @param[in] displacements displacements for repetitions
* @param[in] config configuration object for custom settings
*
*/
Xt_redist xt_redist_repeat_custom_new(Xt_redist redist, MPI_Aint src_extent,
MPI_Aint dst_extent, int num_repetitions,
const int displacements[num_repetitions],
Xt_config config);
/**
* constructor for a redistribution that has a repetitive pattern, which
* is described by the given redistribution. Uses default settings.
* @param[in] redist redistribution
* @param[in] src_extent extent that scales the given displacements
* for the source data
* @param[in] dst_extent extent that scales the given displacements
* for the destination data
* @param[in] num_repetitions number of repetitions of the given
* redistribution
* @param[in] src_displacements displacements for source repetitions
*
* @param[in] dst_displacements displacements for destination repetitions
*
*/
Xt_redist
xt_redist_repeat_asym_new(Xt_redist redist, MPI_Aint src_extent,
MPI_Aint dst_extent, int num_repetitions,
const int src_displacements[num_repetitions],
const int dst_displacements[num_repetitions]);
/**
* constructor for a redistribution that has a repetitive pattern, which
* is described by the given redistribution. Uses custom settings.
* @param[in] redist redistribution
* @param[in] src_extent extent that scales the given displacements
* for the source data
......@@ -94,10 +135,12 @@ Xt_redist xt_redist_repeat_new(Xt_redist redist, MPI_Aint src_extent,
* @param[in] dst_displacements displacements for destination repetitions
*
*/
Xt_redist xt_redist_repeat_asym_new(Xt_redist redist, MPI_Aint src_extent,
MPI_Aint dst_extent, int num_repetitions,
const int src_displacements[num_repetitions],
const int dst_displacements[num_repetitions]);
Xt_redist
xt_redist_repeat_asym_custom_new(Xt_redist redist, MPI_Aint src_extent,
MPI_Aint dst_extent, int num_repetitions,
const int src_displacements[num_repetitions],
const int dst_displacements[num_repetitions],
Xt_config config);
#endif // XT_REDIST_REPEAT_H
......
......@@ -53,6 +53,7 @@
#include <mpi.h>
#include "xt/xt_config.h"
#include "xt/xt_xmap.h"
#include "xt/xt_redist.h"
......@@ -67,7 +68,7 @@
/**
* constructor for a redistribution using point to point
* communication for the exchange
* communication for the exchange using default configuration
* @param[in] nsend number of send messages
* @param[in] nrecv number of receive messages
* @param[in] send_msgs array with send messages
......@@ -81,6 +82,22 @@ xt_redist_single_array_base_new(int nsend, int nrecv,
const struct Xt_redist_msg recv_msgs[],
MPI_Comm comm);
/**
* constructor for a redistribution using point to point
* communication for the exchange with custom configuration
* @param[in] nsend number of send messages
* @param[in] nrecv number of receive messages
* @param[in] send_msgs array with send messages
* @param[in] recv_msgs array with receive messages
* @param[in] comm MPI communicator that is to be used for the
* communication
*/
Xt_redist
xt_redist_single_array_base_custom_new(int nsend, int nrecv,
const struct Xt_redist_msg send_msgs[],
const struct Xt_redist_msg recv_msgs[],
MPI_Comm comm, Xt_config config);
#endif // XT_REDIST_SINGLE_ARRAY_BASE_H
/*
......
/**
* @file xt_config_internal.c
* @brief implementation of configuration object
*
* @copyright Copyright (C) 2020 Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*
* @author Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*/
/*
* Maintainer: Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*
* URL: https://doc.redmine.dkrz.de/yaxt/html/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the DKRZ GmbH nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <mpi.h>
#include <xt/xt_config.h>
#include "xt_config_internal.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/ppm_xfuncs.h"
const struct Xt_config_ xt_default_config = {
.exchanger_new = xt_exchanger_mix_isend_irecv_new,
};
Xt_config xt_config_new(void)
{
Xt_config config = xmalloc(sizeof(*config));
*config = xt_default_config;
return config;
}
void xt_config_delete(Xt_config config)
{
free(config);
}
/*
* Local Variables:
* c-basic-offset: 2
* coding: utf-8
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
/**
* @file xt_config_internal.c
* @brief implementation of configuration object
*
* @copyright Copyright (C) 2020 Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*
* @author Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*/
/*
* Maintainer: Jörg Behrens <behrens@dkrz.de>
* Moritz Hanke <hanke@dkrz.de>
* Thomas Jahns <jahns@dkrz.de>
*
* URL: https://doc.redmine.dkrz.de/yaxt/html/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the DKRZ GmbH nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <mpi.h>
#include <xt/xt_redist.h>