home *** CD-ROM | disk | FTP | other *** search
- /* Copyright, 1990, Regents of the University of Colorado */
- /* This file contains functions for easy manipulation of DINO distributed
- * arrays where each processor can have different sized pieces. */
-
- typedef struct {
- int left; /* First element of home data */
- int right; /* Last element of home data */
- int lover; /* First element of overlap data */
- int rover; /* Last element of overlap data */
- } map_var;
-
- /* This function computes a map variable for a given axis of a distributed
- * array, given the size of the axis, the size of the environment axis it
- * is mapped to, the index number for that axis, and the left and right
- * overlaps. */
-
- void set_map_var (n_, p_, i_, l_, r_, M_)
- int n_; /* Size of the axis */
- int p_; /* Size of the environment axis it's mapped to */
- int i_; /* The index of this environment */
- int l_; /* The left overlap of the mapping */
- int r_; /* The right overlap of the mapping */
- map_var *M_; /* The result variable */
-
- {
- M_->left = i_ * (n_/p_) + (i_ < n_%p_ ? i_ : n_%p_);
- M_->right = (i_ + 1) * (n_/p_) + ((i_ + 1) < n_%p_ ? i_ : n_%p_ - 1);
- M_->lover = (M_->left > l_ ? M_->left - l_ : 0);
- M_->rover = (M_->right + r_ < n_ ? M_->right + r_ : n_ - 1);
- }
-
- /* This function modifies a map variable to only use elements of the array
- * which are within the given bounds. */
-
- void limit_map_var (l_, r_, M_)
- int l_; /* Left limit */
- int r_; /* Right limit */
- map_var *M_; /* The map variable */
-
- {
- if (M_->left < l_) M_->left = l_;
- if (M_->lover < l_) M_->lover = l_;
- if (M_->right > r_) M_->right = r_;
- if (M_->rover > r_) M_->rover = r_;
- }
-