Skip to content
Snippets Groups Projects
Commit f778cd7f authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Use data in text segment and initialization at declaration.

parent b7523abb
No related branches found
No related tags found
No related merge requests found
......@@ -54,18 +54,18 @@ int main(void) {
for (int i = 0; i < 16; ++i) {
Xt_idxlist idxsection;
Xt_int start = 0;
int num_dimensions = 2;
Xt_int global_size[4][2] = {{5,10},{5,-10},{-5,10},{-5,-10}};
int local_size [4][2] = {{3,4},{3,-4},{-3,4},{-3,-4}};
Xt_int local_start[2] = {1,2};
enum { num_dimensions = 2 };
static const Xt_int global_size[4][2] = {{5,10},{5,-10},{-5,10},{-5,-10}};
static const int local_size [4][2] = {{3,4},{3,-4},{-3,4},{-3,-4}};
static const Xt_int local_start[2] = {1,2};
// create index section
idxsection = xt_idxsection_new(start, num_dimensions, global_size[i >> 2],
local_size[i & 3], local_start);
Xt_idxlist idxsection
= xt_idxsection_new(start, num_dimensions, global_size[i >> 2],
local_size[i & 3], local_start);
// testing
......@@ -83,18 +83,18 @@ int main(void) {
{ // test 2D section with stride in x
//! [custom stride in x]
Xt_idxlist idxsection;
Xt_int start = 0;
int num_dimensions = 3;
Xt_int global_size[3] = {5,5,2};
int local_size [3] = {3,4,1};
Xt_int local_start[3] = {2,0,1};
enum { num_dimensions = 3 };
static const Xt_int global_size[3] = {5,5,2};
static const int local_size [3] = {3,4,1};
static const Xt_int local_start[3] = {2,0,1};
// create index section
idxsection = xt_idxsection_new(start, num_dimensions, global_size,
local_size, local_start);
Xt_idxlist idxsection
= xt_idxsection_new(start, num_dimensions, global_size,
local_size, local_start);
//! [custom stride in x]
// testing
......@@ -110,18 +110,18 @@ int main(void) {
{ // test 2D section with stride in x and y
//! [custom stride in x and y]
Xt_idxlist idxsection;
Xt_int start = 0;
int num_dimensions = 4;
Xt_int global_size[4] = {3,2,5,2};
int local_size [4] = {3,1,4,1};
Xt_int local_start[4] = {0,1,1,0};
enum { num_dimensions = 4 };
static const Xt_int global_size[4] = {3,2,5,2};
static const int local_size [4] = {3,1,4,1};
static const Xt_int local_start[4] = {0,1,1,0};
// create index section
idxsection = xt_idxsection_new(start, num_dimensions, global_size,
local_size, local_start);
Xt_idxlist idxsection
= xt_idxsection_new(start, num_dimensions, global_size,
local_size, local_start);
//! [custom stride in x and y]
// testing
......
......@@ -69,7 +69,7 @@ int main(void) {
{
// init source and destination data array, local data 5 elements length
int len = 5;
enum { len = 5 };
int src_array[len];
int dst_array[len];
......@@ -87,30 +87,24 @@ int main(void) {
// output barrier
MPI_Barrier (MPI_COMM_WORLD);
// source index list by stripes
Xt_idxlist src_idxlist;
struct Xt_stripe src_stripes = {.start = (Xt_int)(rank*len), .stride = 1, .nstrides = len};
src_idxlist = xt_idxstripes_new(&src_stripes, 1);
// destination index list by stripes
Xt_idxlist dst_idxlist;
// source index list by stripes
Xt_idxlist src_idxlist = xt_idxstripes_new(&src_stripes, 1);
struct Xt_stripe dst_stripes = {.start = (Xt_int)(((rank+1)*len)%(size*len)),
.stride = 1, .nstrides = len};
dst_idxlist = xt_idxstripes_new(&dst_stripes, 1);
// destination index list by stripes
Xt_idxlist dst_idxlist = xt_idxstripes_new(&dst_stripes, 1);
// xmap
Xt_xmap xmap;
xmap = xt_xmap_all2all_new(src_idxlist, dst_idxlist, MPI_COMM_WORLD);
Xt_xmap xmap
= xt_xmap_all2all_new(src_idxlist, dst_idxlist, MPI_COMM_WORLD);
// redist_p2p
Xt_redist redist;
redist = xt_redist_p2p_new(xmap, MPI_INTEGER);
Xt_redist redist = xt_redist_p2p_new(xmap, MPI_INTEGER);
//array poiter, especially necessary for data array number > 1
// array pointer, especially necessary for data array number > 1
int* src_array_p = &src_array[0];
int* dst_array_p = &dst_array[0];
......
......@@ -357,17 +357,16 @@ int main(int argc, char** argv) {
get_config(&conf, argc, argv, nprocs);
// global param
int num_dims = 3;
enum { num_dims = 3 };
Xt_int global_size[3] = {(Xt_int)conf.z, (Xt_int)conf.y, (Xt_int)conf.x};
// -- SOURCE index list by section
Xt_idxlist src_idxsection;
Xt_int start = 0;
//create source index section
src_idxsection = xt_idxsection_new(start, num_dims, global_size,
conf.src.local_size,
conf.src.local_start);
Xt_idxlist src_idxsection
= xt_idxsection_new(start, num_dims, global_size,
conf.src.local_size, conf.src.local_start);
#ifdef DEBUG
// 0 = soruce
......@@ -376,25 +375,21 @@ int main(int argc, char** argv) {
#endif
// --- DEST-ination index list by section
Xt_idxlist dst_idxsection;
dst_idxsection = xt_idxsection_new(start, num_dims, global_size,
conf.dst.local_size,
conf.dst.local_start);
Xt_idxlist dst_idxsection
= xt_idxsection_new(start, num_dims, global_size,
conf.dst.local_size, conf.dst.local_start);
// 1 = dest
#ifdef DEBUG
print_index(dst_idxsection, rank, DESTINATION);
#endif
// xmap
Xt_xmap xmap;
xmap = xt_xmap_all2all_new(src_idxsection, dst_idxsection, MPI_COMM_WORLD);
Xt_xmap xmap
= xt_xmap_all2all_new(src_idxsection, dst_idxsection, MPI_COMM_WORLD);
// redist_p2p
Xt_redist redist;
redist = xt_redist_p2p_new(xmap, MPI_INTEGER);
Xt_redist redist
= xt_redist_p2p_new(xmap, MPI_INT);
// --- local data array
int *src_array, *dst_array;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment