示例#1
0
std::string SialPrinterForTests::BlockId2String(const BlockId& id){

		std::stringstream ss;
		bool contiguous_local = sip_tables_.is_contiguous_local(id.array_id());
		if (contiguous_local) ss << "contiguous local ";
		int rank = sip_tables_.array_rank(id.array_id());
		ss << sip_tables_.array_name(id.array_id()) ;
		ss << '[';
		int i;
		for (i = 0; i < rank; ++i) {
			ss << (i == 0 ? "" : ",") << id.index_values(i);
			if (contiguous_local) ss << ":" << id.upper_index_values(i);
		}
		ss << ']';
		return ss.str();
	}
Block::BlockPtr ContiguousArrayManager::get_block(const BlockId& block_id, int& rank,
		Block::BlockPtr& contiguous, sip::offset_array_t& offsets) {
//get contiguous array that contains block block_id, which must exist, and get its selectors and shape
	int array_id = block_id.array_id();
	rank = sip_tables_.array_rank(array_id);
	contiguous = get_array(array_id);
	sip::check(contiguous != NULL, "contiguous array not allocated");
	const sip::index_selector_t& selector = sip_tables_.selectors(array_id);
	BlockShape array_shape = sip_tables_.contiguous_array_shape(array_id); //shape of containing contiguous array

//get offsets of block_id in the containing array
	for (int i = 0; i < rank; ++i) {
		offsets[i] = sip_tables_.offset_into_contiguous(selector[i],
				block_id.index_values(i));
	}
//set offsets of unused indices to 0
	std::fill(offsets + rank, offsets + MAX_RANK, 0);

//get shape of subblock
	BlockShape block_shape = sip_tables_.shape(block_id);

//allocate a new block and copy data from contiguous block
	Block::BlockPtr block = new Block(block_shape);
	contiguous->extract_slice(rank, offsets, block);
	return block;
}
示例#3
0
Block::BlockPtr SialOpsParallel::get_block_for_updating(const BlockId& id) {
	int array_id = id.array_id();
	check(
			!(sip_tables_.is_distributed(array_id)
					|| sip_tables_.is_served(array_id)),
			"attempting to update distributed or served block", current_line());

	return block_manager_.get_block_for_updating(id);
}
示例#4
0
Block::BlockPtr SialOpsParallel::get_block_for_reading(const BlockId& id, int line) {
	int array_id = id.array_id();
	if (sip_tables_.is_distributed(array_id)
			|| sip_tables_.is_served(array_id)) {
		check_and_set_mode(array_id, READ);
		return wait_and_check(block_manager_.get_block_for_reading(id), line);
	}
	return block_manager_.get_block_for_reading(id);
}
示例#5
0
Block::BlockPtr SialOpsParallel::get_block_for_writing(const BlockId& id,
		bool is_scope_extent) {
	int array_id = id.array_id();
	if (sip_tables_.is_distributed(array_id)
			|| sip_tables_.is_served(array_id)) {
		check(!is_scope_extent,
				"sip bug: asking for scope-extend dist or served block");
		check_and_set_mode(array_id, WRITE);
	}
	return block_manager_.get_block_for_writing(id, is_scope_extent);
}
示例#6
0
void BlockManager::gen(const BlockId& id, int rank, const int pos,
		std::vector<int> prefix /*pass by value*/, int to_append,
		std::vector<BlockId>& list) {
	if (pos != 0) {
		prefix.push_back(to_append);
	}
	if (pos < rank) {
		int curr_index = id.index_values(pos);
		if (curr_index == wild_card_value) {
			int index_slot = sip_tables_.selectors(id.array_id())[pos];
			int lower = sip_tables_.lower_seg(index_slot);
			int upper = lower + sip_tables_.num_segments(index_slot);
			for (int i = lower; i < upper; ++i) {
				gen(id, rank, pos + 1, prefix, i, list);
			}
		} else {
			gen(id, rank, pos + 1, prefix, curr_index, list);
		}

	} else {
		list.push_back(BlockId(id.array_id(), rank, prefix));
	}
}
示例#7
0
bool SialOpsParallel::check_and_set_mode(const BlockId& id, array_mode mode) {
	int array_id = id.array_id();
	return check_and_set_mode(array_id, mode);
}