Exemplo n.º 1
0
 void
 mAllocate(
     int64_t len,
     Legion::Context &ctx,
     Legion::HighLevelRuntime *lrt
 ) {
     mLength = len;
     // calculate the size of the logicalRegion vec (inclusive)
     size_t n = mLength - 1;
     // vec rect
     bounds = Rect<1>(Point<1>::ZEROES(), Point<1>(n));
     // vector domain
     Domain dom(Domain::from_rect<1>(bounds));
     // vec index space
     mIndexSpace = lrt->create_index_space(ctx, dom);
     // vec field space
     mFS = lrt->create_field_space(ctx);
     // vec field allocator
     FieldAllocator fa = lrt->create_field_allocator(ctx, mFS);
     // all elements are going to be of size T
     fa.allocate_field(sizeof(TYPE), fid);
     // now create the logical region
     logicalRegion = lrt->create_logical_region(ctx, mIndexSpace, mFS);
     // stash some info for equality checks
     mIndexSpaceID = logicalRegion.get_index_space().get_id();
     mFieldSpaceID = logicalRegion.get_field_space().get_id();
     mRTreeID      = logicalRegion.get_tree_id();
 }
Exemplo n.º 2
0
Array<T>::Array(int64_t size, int64_t nparts, Context ctx, HighLevelRuntime *runtime){

	this-> fid = FID_X;
	this-> size = size;
	this-> nparts = nparts;

	rect = Rect<1>(Point<1>(0), Point<1>(size-1));
	is = runtime->create_index_space(ctx, Domain::from_rect<1>(rect));

  //printf("Inside ARRAY::ARRAY!!\n");
  //IndexIterator itr_read(runtime, ctx, is);


	fs = runtime->create_field_space(ctx);

	{
		FieldAllocator allocator = runtime->create_field_allocator(ctx, fs);
		allocator.allocate_field(sizeof(int64_t), FID_X);
	}

	lr = runtime->create_logical_region(ctx, is, fs);

	// partition the logical region
	Rect<1> color_bounds(Point<1>(0), Point<1>(nparts-1));
	color_domain = Domain::from_rect<1>(color_bounds);
	
	DomainColoring coloring;
	int index = 0;
	const int local_size = (size + nparts -1) / nparts;
	for(int color = 0; color < nparts-1; color++){
		assert((index + local_size) <= size);
		Rect<1> subrect(Point<1>(index), Point<1>(index + local_size - 1));
		coloring[color] = Domain::from_rect<1>(subrect);
		index += local_size;
	}
	Rect<1> subrect(Point<1>(index), Point<1>(size-1));
	coloring[nparts-1] = Domain::from_rect<1>(subrect);

	ip = runtime->create_index_partition(ctx, is, color_domain,
					     coloring, true/*disjoint*/);
	lp = runtime->get_logical_partition(ctx, lr, ip);

}
SpMatrix::SpMatrix(int64_t n, int64_t nparts, int64_t nonzeros, int64_t max_nzeros, Context ctx, HighLevelRuntime *runtime){

	this-> row_fid = FID_NZEROS_PER_ROW;	
	this-> val_fid = FID_Vals;
	this-> col_fid = FID_Col_Ind;
	this-> nrows = n;
	this-> ncols = n;
	this-> nonzeros = nonzeros;
	this-> max_nzeros = max_nzeros;
	this-> nparts = nparts;
	
	// build logical region for row_ptr
	row_rect = Rect<1>(Point<1>(0), Point<1>(nrows-1));
	row_is = runtime->create_index_space(ctx,
			  Domain::from_rect<1>(row_rect));
	row_fs = runtime->create_field_space(ctx);
	{
		FieldAllocator allocator = runtime->create_field_allocator(ctx, row_fs);
		allocator.allocate_field(sizeof(int64_t), FID_NZEROS_PER_ROW);
	}
	row_lr = runtime->create_logical_region(ctx, row_is, row_fs);

	// build logical region for matrix nonzero values
	elem_rect = Rect<1>(Point<1>(0), Point<1>(max_nzeros*nrows-1));
	elem_is = runtime->create_index_space(ctx,
			   Domain::from_rect<1>(elem_rect));
	elem_fs = runtime->create_field_space(ctx);
	{
		FieldAllocator allocator = runtime->create_field_allocator(ctx, elem_fs);
		allocator.allocate_field(sizeof(double), FID_Vals);
		allocator.allocate_field(sizeof(int64_t), FID_Col_Ind);
	}
	elem_lr = runtime->create_logical_region(ctx, elem_is, elem_fs);

	Rect<1> color_bounds(Point<1>(0), Point<1>(nparts-1));
	color_domain = Domain::from_rect<1>(color_bounds);

	// partition the row logical region
	DomainColoring row_coloring;
	int index = 0;
	const int local_num_rows = (nrows + nparts - 1) / nparts;
	for(int color = 0; color < nparts-1; color++){
		assert((index + local_num_rows) <= nrows);
		Rect<1> subrect(Point<1>(index), Point<1>(index + local_num_rows - 1));
		row_coloring[color] = Domain::from_rect<1>(subrect);
		index += local_num_rows;
	}
	Rect<1> subrect(Point<1>(index), Point<1>(nrows-1));
        row_coloring[nparts-1] = Domain::from_rect<1>(subrect);

	row_ip = runtime->create_index_partition(ctx, row_is, color_domain,
						 row_coloring, true/*disjoint*/);
	row_lp = runtime->get_logical_partition(ctx, row_lr, row_ip);

	// partition the nonzero values logical region
	index = 0;
	DomainColoring elem_coloring;
	const int local_num_nzeros = local_num_rows * max_nzeros;
	for(int color = 0; color < nparts-1; color++){
		Rect<1> subrect1(Point<1>(index), Point<1>(index + local_num_nzeros -1));
		elem_coloring[color] = Domain::from_rect<1>(subrect1);
		index += local_num_nzeros;
	}
	Rect<1> subrect1(Point<1>(index), Point<1>(nrows*max_nzeros - 1));
	elem_coloring[nparts-1] = Domain::from_rect<1>(subrect1);

	elem_ip = runtime->create_index_partition(ctx, elem_is, color_domain,
						  elem_coloring, true/*disjoint*/); 	
	elem_lp = runtime->get_logical_partition(ctx, elem_lr, elem_ip);

}