(git:27c966b)
Loading...
Searching...
No Matches
dbm_multiply_comm.c File Reference
#include "dbm_multiply_comm.h"
#include "../mpiwrap/cp_mpi.h"
#include "../offload/offload_mempool.h"
#include <assert.h>
#include <limits.h>
#include <omp.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  plan_t
 Private struct used for planing during pack_matrix. More...

Macros

#define DBM_MULTIPLY_COMM_MEMPOOL

Functions

static void * allocate_comm_buffer (const size_t size)
 Private routine for allocating a communication buffer, which is taken from the memory pool (DBM_MULTIPLY_COMM_MEMPOOL) rather than mapping fresh pages for every multiplication.
static void free_comm_buffer (void *mem)
 Private routine for releasing a buffer from allocate_comm_buffer.
static int gcd (const int a, const int b)
 Private routine for computing greatest common divisor of two numbers.
static int lcm (const int a, const int b)
 Private routine for computing least common multiple of two numbers.
static int checked_byte_count (const int nelements, const size_t element_size)
 Private routine for converting element counts to byte counts.
static int isum (const int n, const int input[n])
 Private routine for computing the sum of the given integers.
static void icumsum (const int n, const int input[n], int output[n])
 Private routine for computing the cumulative sums of given numbers.
static void compute_data_recv_count (const int nranks, const int blks_recv_count[nranks], const int blks_recv_displ[nranks], const int free_index_sizes[], const int sum_index_sizes[], const dbm_pack_block_t blks_recv[], int data_recv_count[nranks])
 Private routine computing received data counts from block metadata.
static unsigned long long calculate_tick_index (int sum_index, int nticks)
 Private routine for calculating tick indices in pack plans.
static void create_pack_plans (const bool trans_matrix, const bool trans_dist, const dbm_matrix_t *matrix, const cp_mpi_comm_t comm, const dbm_dist_1d_t *dist_indices, const dbm_dist_1d_t *dist_ticks, const int nticks, const int npacks, plan_t *plans_per_pack[npacks], int nblks_per_pack[npacks], int ndata_per_pack[npacks])
 Private routine for planing packs.
static void copy_pack_block (const bool trans_matrix, const dbm_block_t *blk, const int row_size, const int col_size, const double shard_data[], double pack_data[], const int offset, dbm_pack_block_t *pack_block)
 Private routine for copying a block and computing its squared norm.
static void fill_send_buffers (const dbm_matrix_t *matrix, const bool trans_matrix, const int nblks_send, const int ndata_send, plan_t plans[nblks_send], const int nranks, int blks_send_count[nranks], int data_send_count[nranks], int blks_send_displ[nranks], int data_send_displ[nranks], dbm_pack_block_t blks_send[nblks_send], double data_send[ndata_send])
 Private routine for filling send buffers.
static int compare_pack_blocks_by_sum_index (const void *a, const void *b)
 Private comperator passed to qsort to compare two blocks by sum_index.
static dbm_pack_t pack_local_matrix (const bool trans_matrix, const dbm_matrix_t *matrix, const int nshards, double *seconds_sort)
 Private routine for packing a local matrix directly by target shard.
static void postprocess_received_blocks (const int nranks, const int nshards, const int nblocks_recv, const int blks_recv_count[nranks], const int blks_recv_displ[nranks], const int data_recv_displ[nranks], dbm_pack_block_t blks_recv[nblocks_recv])
 Private routine for post-processing received blocks.
static dbm_packed_matrix_t pack_matrix (const bool trans_matrix, const bool trans_dist, const dbm_matrix_t *restrict matrix, const dbm_distribution_t *restrict dist, const int nticks, dbm_comm_iterator_t *iter)
 Private routine for redistributing a matrix along selected dimensions.
static dbm_pack_t * sendrecv_pack (const int itick, const int nticks, dbm_packed_matrix_t *packed, int64_t *bytes)
 Private routine for sending and receiving the pack for the given tick.
static void free_packed_matrix (dbm_packed_matrix_t *packed)
 Private routine for releasing a packed matrix.
dbm_comm_iterator_t * dbm_comm_iterator_start (const bool transa, const bool transb, const dbm_matrix_t *matrix_a, const dbm_matrix_t *matrix_b, const dbm_matrix_t *matrix_c)
 Internal routine for creating a communication iterator.
bool dbm_comm_iterator_next (dbm_comm_iterator_t *iter, dbm_pack_t **pack_a, dbm_pack_t **pack_b)
 Internal routine for retrieving next pair of packs of given iterator.
void dbm_comm_iterator_stop (dbm_comm_iterator_t *iter)
 Internal routine for releasing the given communication iterator.

Macro Definition Documentation

◆ DBM_MULTIPLY_COMM_MEMPOOL

#define DBM_MULTIPLY_COMM_MEMPOOL

Definition at line 18 of file dbm_multiply_comm.c.

Function Documentation

◆ allocate_comm_buffer()

void * allocate_comm_buffer ( const size_t size)
static

Private routine for allocating a communication buffer, which is taken from the memory pool (DBM_MULTIPLY_COMM_MEMPOOL) rather than mapping fresh pages for every multiplication.

Author
Hans Pabst

Definition at line 27 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_comm_buffer()

void free_comm_buffer ( void * mem)
static

Private routine for releasing a buffer from allocate_comm_buffer.

Author
Hans Pabst

Definition at line 39 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gcd()

int gcd ( const int a,
const int b )
static

Private routine for computing greatest common divisor of two numbers.

Author
Ole Schuett

Definition at line 51 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lcm()

int lcm ( const int a,
const int b )
static

Private routine for computing least common multiple of two numbers.

Author
Ole Schuett

Definition at line 62 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checked_byte_count()

int checked_byte_count ( const int nelements,
const size_t element_size )
static

Private routine for converting element counts to byte counts.

Author
Hans Pabst

Definition at line 68 of file dbm_multiply_comm.c.

Here is the caller graph for this function:

◆ isum()

int isum ( const int n,
const int input[n] )
inlinestatic

Private routine for computing the sum of the given integers.

Author
Ole Schuett

Definition at line 81 of file dbm_multiply_comm.c.

Here is the caller graph for this function:

◆ icumsum()

void icumsum ( const int n,
const int input[n],
int output[n] )
inlinestatic

Private routine for computing the cumulative sums of given numbers.

Author
Ole Schuett and Hans Pabst

Definition at line 93 of file dbm_multiply_comm.c.

Here is the caller graph for this function:

◆ compute_data_recv_count()

void compute_data_recv_count ( const int nranks,
const int blks_recv_count[nranks],
const int blks_recv_displ[nranks],
const int free_index_sizes[],
const int sum_index_sizes[],
const dbm_pack_block_t blks_recv[],
int data_recv_count[nranks] )
static

Private routine computing received data counts from block metadata.

Author
Hans Pabst

Definition at line 107 of file dbm_multiply_comm.c.

Here is the caller graph for this function:

◆ calculate_tick_index()

unsigned long long calculate_tick_index ( int sum_index,
int nticks )
inlinestatic

Private routine for calculating tick indices in pack plans.

Author
Maximilian Graml

Definition at line 145 of file dbm_multiply_comm.c.

Here is the caller graph for this function:

◆ create_pack_plans()

void create_pack_plans ( const bool trans_matrix,
const bool trans_dist,
const dbm_matrix_t * matrix,
const cp_mpi_comm_t comm,
const dbm_dist_1d_t * dist_indices,
const dbm_dist_1d_t * dist_ticks,
const int nticks,
const int npacks,
plan_t * plans_per_pack[npacks],
int nblks_per_pack[npacks],
int ndata_per_pack[npacks] )
static

Private routine for planing packs.

Author
Ole Schuett

Definition at line 155 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_pack_block()

void copy_pack_block ( const bool trans_matrix,
const dbm_block_t * blk,
const int row_size,
const int col_size,
const double shard_data[],
double pack_data[],
const int offset,
dbm_pack_block_t * pack_block )
static

Private routine for copying a block and computing its squared norm.

Definition at line 236 of file dbm_multiply_comm.c.

Here is the caller graph for this function:

◆ fill_send_buffers()

void fill_send_buffers ( const dbm_matrix_t * matrix,
const bool trans_matrix,
const int nblks_send,
const int ndata_send,
plan_t plans[nblks_send],
const int nranks,
int blks_send_count[nranks],
int data_send_count[nranks],
int blks_send_displ[nranks],
int data_send_displ[nranks],
dbm_pack_block_t blks_send[nblks_send],
double data_send[ndata_send] )
static

Private routine for filling send buffers.

Author
Ole Schuett

Definition at line 269 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare_pack_blocks_by_sum_index()

int compare_pack_blocks_by_sum_index ( const void * a,
const void * b )
static

Private comperator passed to qsort to compare two blocks by sum_index.

Author
Ole Schuett

Definition at line 343 of file dbm_multiply_comm.c.

Here is the caller graph for this function:

◆ pack_local_matrix()

dbm_pack_t pack_local_matrix ( const bool trans_matrix,
const dbm_matrix_t * matrix,
const int nshards,
double * seconds_sort )
static

Private routine for packing a local matrix directly by target shard.

Definition at line 352 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ postprocess_received_blocks()

void postprocess_received_blocks ( const int nranks,
const int nshards,
const int nblocks_recv,
const int blks_recv_count[nranks],
const int blks_recv_displ[nranks],
const int data_recv_displ[nranks],
dbm_pack_block_t blks_recv[nblocks_recv] )
static

Private routine for post-processing received blocks.

Author
Ole Schuett

Definition at line 452 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_matrix()

dbm_packed_matrix_t pack_matrix ( const bool trans_matrix,
const bool trans_dist,
const dbm_matrix_t *restrict matrix,
const dbm_distribution_t *restrict dist,
const int nticks,
dbm_comm_iterator_t * iter )
static

Private routine for redistributing a matrix along selected dimensions.

Author
Ole Schuett

Definition at line 527 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendrecv_pack()

dbm_pack_t * sendrecv_pack ( const int itick,
const int nticks,
dbm_packed_matrix_t * packed,
int64_t * bytes )
static

Private routine for sending and receiving the pack for the given tick.

Author
Ole Schuett

Definition at line 678 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_packed_matrix()

void free_packed_matrix ( dbm_packed_matrix_t * packed)
static

Private routine for releasing a packed matrix.

Author
Ole Schuett

Definition at line 738 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbm_comm_iterator_start()

dbm_comm_iterator_t * dbm_comm_iterator_start ( const bool transa,
const bool transb,
const dbm_matrix_t * matrix_a,
const dbm_matrix_t * matrix_b,
const dbm_matrix_t * matrix_c )

Internal routine for creating a communication iterator.

Author
Ole Schuett

Definition at line 752 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbm_comm_iterator_next()

bool dbm_comm_iterator_next ( dbm_comm_iterator_t * iter,
dbm_pack_t ** pack_a,
dbm_pack_t ** pack_b )

Internal routine for retrieving next pair of packs of given iterator.

Internal routine for retrieving next pair of packs.

Author
Ole Schuett

Definition at line 782 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbm_comm_iterator_stop()

void dbm_comm_iterator_stop ( dbm_comm_iterator_t * iter)

Internal routine for releasing the given communication iterator.

Author
Ole Schuett

Definition at line 804 of file dbm_multiply_comm.c.

Here is the call graph for this function:
Here is the caller graph for this function: