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

Use configuration item in list intersections.

parent 762da78c
......@@ -52,6 +52,7 @@
#endif
#include <stdlib.h>
#include "xt/xt_config.h"
#include "xt/xt_core.h"
#include "xt/xt_stripe.h"
......@@ -160,6 +161,23 @@ Xt_idxlist xt_idxlist_unpack(void* buffer, int buffer_size,
Xt_idxlist
xt_idxlist_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst);
/**
* computes the intersection between two index lists with custom
* configuration
*
* @param[in] idxlist_src index list for sender
* @param[in] idxlist_dst index list for receiver
* @param[in] config custom configuration parameters
* @return return the intersection of idxlist_a and idxlist_b
* @remark multiple occurrences of an element in idxlist_dst will result in
* multiple occurrences of the element in the intersection if
* idxlist_src contains it
* @remark the elements in the resulting index list are sorted
*/
Xt_idxlist
xt_idxlist_get_intersection_custom(Xt_idxlist idxlist_src,
Xt_idxlist idxlist_dst, Xt_config config);
/**
* generates a copy of a given index list
*
......
......@@ -80,6 +80,22 @@
Xt_xmap xt_xmap_all2all_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist,
MPI_Comm comm);
/**
* constructor for an exchange map with custom parameters\n
* this operation is collective over all processes in comm \n
* it uses all-to-all communication for the initialisation
*
* @param[in] src_idxlist source index list
* @param[in] dst_idxlist destination index list
* @param[in] comm MPI communicator that contains all processes
* that take part in the exchange (xt_xmap_all2all_new
* will make its own copy of comm)
* @param[in] config custom parameters
*/
Xt_xmap
xt_xmap_all2all_custom_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist,
MPI_Comm comm, Xt_config config);
#endif // XT_XMAP_ALL2ALL_H
/*
......
......@@ -252,7 +252,8 @@ xt_idxlist_collection_unpack(void *buffer, int buffer_size, int *position,
Xt_idxlist
xt_idxlist_collection_get_intersection(Xt_idxlist XT_UNUSED(idxlist_src),
Xt_idxlist XT_UNUSED(idxlist_dst)) {
Xt_idxlist XT_UNUSED(idxlist_dst),
Xt_config XT_UNUSED(config)) {
return NULL;
}
......
......@@ -54,7 +54,8 @@
Xt_idxlist
xt_idxlist_collection_get_intersection(Xt_idxlist idxlist_src,
Xt_idxlist idxlist_dst);
Xt_idxlist idxlist_dst,
Xt_config config);
#endif
......
......@@ -51,6 +51,7 @@
#include <config.h>
#endif
#include "xt/xt_config.h"
#include "xt/xt_core.h"
#include "xt/xt_idxlist.h"
......@@ -109,7 +110,8 @@ static inline void Xt_idxlist_init(Xt_idxlist idxlist,
}
Xt_idxlist
xt_default_isect(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst);
xt_default_isect(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst,
Xt_config config);
/*
* for index lists this large, stripe representation generally gives
......
......@@ -58,12 +58,14 @@
#include "xt_idxempty_internal.h"
#include "xt_idxlist_collection_internal.h"
#include "xt/xt_idxvec.h"
#include "xt_config_internal.h"
#include "xt_idxvec_internal.h"
#include "xt_idxsection_internal.h"
#include "xt_idxstripes_internal.h"
typedef Xt_idxlist (*intersection_get)(Xt_idxlist idxlist_src,
Xt_idxlist idxlist_dst);
Xt_idxlist idxlist_dst,
Xt_config config);
#define empty_isect ((intersection_get)(void (*)(void))xt_idxempty_new)
......@@ -89,14 +91,23 @@ void xt_idxlist_intersection_init(void)
Xt_idxlist
xt_idxlist_get_intersection(Xt_idxlist idxlist_src,
Xt_idxlist idxlist_dst)
{
return xt_idxlist_get_intersection_custom(idxlist_src, idxlist_dst,
&xt_default_config);
}
Xt_idxlist
xt_idxlist_get_intersection_custom(Xt_idxlist idxlist_src,
Xt_idxlist idxlist_dst, Xt_config config)
{
return intersection_get_matrix[idxlist_src->vtable->idxlist_pack_code]
[idxlist_dst->vtable->idxlist_pack_code](idxlist_src, idxlist_dst);
[idxlist_dst->vtable->idxlist_pack_code](idxlist_src, idxlist_dst, config);
}
Xt_idxlist
xt_default_isect(Xt_idxlist idxlist_src,
Xt_idxlist idxlist_dst)
Xt_idxlist idxlist_dst,
Xt_config config)
{
INSTR_DEF(instr_fallback,"xt_idxlist_get_intersection.fallback")
......@@ -111,8 +122,8 @@ xt_default_isect(Xt_idxlist idxlist_src,
return xt_idxempty_new();
Xt_idxlist intersection;
if (num_indices_src < CHEAP_VECTOR_SIZE
&& num_indices_dst < CHEAP_VECTOR_SIZE) {
if (num_indices_src < config->idxv_cnv_size
&& num_indices_dst < config->idxv_cnv_size) {
Xt_int *indices_src
= xmalloc(((size_t)num_indices_src + (size_t)num_indices_dst)
* sizeof (indices_src[0])),
......@@ -125,7 +136,7 @@ xt_default_isect(Xt_idxlist idxlist_src,
idxvec_dst = xt_idxvec_prealloc_new(indices_dst, num_indices_dst);
intersection
= xt_idxvec_get_intersection(idxvec_src, idxvec_dst);
= xt_idxvec_get_intersection(idxvec_src, idxvec_dst, config);
xt_idxlist_delete(idxvec_src);
xt_idxlist_delete(idxvec_dst);
......@@ -140,7 +151,7 @@ xt_default_isect(Xt_idxlist idxlist_src,
idxstripes_dst = xt_idxstripes_prealloc_new(stripes_dst,
num_stripes_dst);
intersection
= xt_idxstripes_get_intersection(idxstripes_src, idxstripes_dst);
= xt_idxstripes_get_intersection(idxstripes_src, idxstripes_dst, config);
xt_idxlist_delete(idxstripes_dst);
xt_idxlist_delete(idxstripes_src);
free(stripes_dst);
......
......@@ -396,8 +396,9 @@ Xt_idxlist xt_idxsection_unpack(void *buffer, int buffer_size, int *position,
Xt_idxlist
xt_idxsection_get_intersection_with_other_idxlist(Xt_idxlist src_idxsection,
Xt_idxlist dst_idxlist) {
Xt_idxlist dst_idxlist,
Xt_config XT_UNUSED(config))
{
// intersection between an idxsection and a general idxlist:
//
// performance picture:
......@@ -463,7 +464,9 @@ xt_idxsection_get_intersection_with_other_idxlist(Xt_idxlist src_idxsection,
}
Xt_idxlist
xt_idxsection_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst) {
xt_idxsection_get_intersection(Xt_idxlist idxlist_src,
Xt_idxlist idxlist_dst,
Xt_config config) {
INSTR_DEF(instr,"idxsection_get_intersection.part")
// both lists are index section:
......@@ -473,7 +476,7 @@ xt_idxsection_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst) {
if (idxsection_src->ndim != idxsection_dst->ndim ||
idxsection_src->global_start_index != idxsection_dst->global_start_index)
return xt_default_isect(idxlist_src, idxlist_dst);
return xt_default_isect(idxlist_src, idxlist_dst, config);
int i;
......@@ -483,7 +486,7 @@ xt_idxsection_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst) {
if (XT_INT_ABS(idxsection_src->dims[i].global_size)
!= XT_INT_ABS(idxsection_dst->dims[i].global_size))
return xt_idxsection_get_intersection_with_other_idxlist(
idxlist_src, idxlist_dst);
idxlist_src, idxlist_dst, config);
Xt_int *local_start, *global_size;
int *local_size;
......
......@@ -59,11 +59,12 @@ void
xt_idxsection_finalize(void);
Xt_idxlist
xt_idxsection_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst);
xt_idxsection_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst,
Xt_config config);
Xt_idxlist
xt_idxsection_get_intersection_with_other_idxlist(Xt_idxlist src_idxsection,
Xt_idxlist dst_idxlist);
xt_idxsection_get_intersection_with_other_idxlist(
Xt_idxlist src_idxsection, Xt_idxlist dst_idxlist, Xt_config config);
#endif
......
......@@ -866,7 +866,8 @@ idxstripes_compute_intersection(Xt_idxstripes idxstripes_src,
}
Xt_idxlist
xt_idxstripes_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst)
xt_idxstripes_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst,
Xt_config XT_UNUSED(config))
{
// both lists are index stripes:
Xt_idxstripes idxstripes_src = (Xt_idxstripes)idxlist_src,
......@@ -911,15 +912,10 @@ idxstripes_get_indices_const(Xt_idxlist idxlist) {
if (idxstripes->index_array_cache) return idxstripes->index_array_cache;
int num_indices = idxlist->num_indices;
Xt_int *tmp_index_array
= xmalloc((size_t)num_indices * sizeof( *(idxstripes->index_array_cache) ) );
= xmalloc((size_t)num_indices * sizeof (*tmp_index_array));
idxstripes_get_indices(idxlist, tmp_index_array);
idxstripes->index_array_cache = tmp_index_array;
return idxstripes->index_array_cache;
return idxstripes->index_array_cache = tmp_index_array;
}
static void
......
......@@ -63,7 +63,8 @@ void
xt_idxstripes_finalize(void);
Xt_idxlist
xt_idxstripes_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst);
xt_idxstripes_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst,
Xt_config config);
/**
* Generates an index list that is built up of stripes of indices.
......
......@@ -489,7 +489,9 @@ get_sorted_vector(Xt_idxvec idxvec) {
}
Xt_idxlist
xt_idxvec_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst) {
xt_idxvec_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst,
Xt_config XT_UNUSED(config))
{
// both lists are index vectors:
......
......@@ -54,7 +54,8 @@
#include "xt/xt_idxlist.h"
Xt_idxlist
xt_idxvec_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst);
xt_idxvec_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst,
Xt_config config);
Xt_idxlist
xt_idxvec_prealloc_new(const Xt_int *idxvec, int num_indices);
......
......@@ -161,7 +161,8 @@ static void exchange_idxlists(struct Xt_com_list **src_intersections,
large_list_seen
|= (xt_idxlist_get_num_indices(src) >= config->idxv_cnv_size)
| (xt_idxlist_get_num_indices(dst) >= config->idxv_cnv_size);
Xt_idxlist intersect = xt_idxlist_get_intersection(src, dst_idxlist_local);
Xt_idxlist intersect
= xt_idxlist_get_intersection_custom(src, dst_idxlist_local, config);
if (xt_idxlist_get_num_indices(intersect) > 0) {
dsti[dst_isect_count].list = intersect;
......@@ -171,7 +172,8 @@ static void exchange_idxlists(struct Xt_com_list **src_intersections,
else
xt_idxlist_delete(intersect);
intersect = xt_idxlist_get_intersection(src_idxlist_local, dst);
intersect
= xt_idxlist_get_intersection_custom(src_idxlist_local, dst, config);
if (xt_idxlist_get_num_indices(intersect) > 0) {
srci[src_isect_count].list = intersect;
......@@ -201,6 +203,14 @@ static void exchange_idxlists(struct Xt_com_list **src_intersections,
*dst_intersections = dsti;
}
Xt_xmap
xt_xmap_all2all_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist,
MPI_Comm comm)
{
return xt_xmap_all2all_custom_new(src_idxlist, dst_idxlist,
comm, &xt_default_config);
}
Xt_xmap
xt_xmap_all2all_custom_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist,
MPI_Comm comm, Xt_config config) {
......@@ -248,14 +258,6 @@ xt_xmap_all2all_custom_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist,
return xmap;
}
Xt_xmap
xt_xmap_all2all_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist,
MPI_Comm comm)
{
return xt_xmap_all2all_custom_new(src_idxlist, dst_idxlist,
comm, &xt_default_config);
}
/*
* Local Variables:
* c-basic-offset: 2
......
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