void SialPrinterForTests::do_print_block(const BlockId& id, Block::BlockPtr block, int line_number){ int MAX_TO_PRINT = 1024; int size = block->size(); int OUTPUT_ROW_SIZE = block->shape().segment_sizes_[0]; double* data = block->get_data(); out_.precision(14); out_.setf(std::ios_base::fixed); out_ << line_number << ": "; if (size == 1) { out_ << "printing " << id.str(sip_tables_) << " = "; out_ << *(data); } else { out_ << "printing " << (size < MAX_TO_PRINT?size:MAX_TO_PRINT); out_ << " of " <<size << " elements of block " << id.str(sip_tables_);//BlockId2String(id); out_ << " in the order stored in memory "; int i; for (i = 0; i < size && i < MAX_TO_PRINT; ++i){ if (i%OUTPUT_ROW_SIZE == 0) out_ << std::endl; out_ << *(data+i) << " "; } if (i == MAX_TO_PRINT){ out_ << "...."; } } out_ << std::endl; }
//TODO TEMPORARY FIX WHILE SEMANTICS BEING WORKED OUT Block::BlockPtr BlockManager::get_block_for_reading(const BlockId& id) { Block::BlockPtr blk = block(id); sial_check(blk != NULL, "Attempting to read non-existent block " + id.str(sip_tables_), current_line()); //// //#ifdef HAVE_CUDA // // Lazy copying of data from gpu to host if needed. // lazy_gpu_read_on_host(blk); //#endif //HAVE_CUDA return blk; }
/* gets block for reading and writing. The block should already exist.*/ Block::BlockPtr BlockManager::get_block_for_updating(const BlockId& id) { // std::cout << "calling get_block_for_updating for " << id << current_line()<<std::endl << std::flush; Block::BlockPtr blk = block(id); if (blk==NULL){ std::cout << *this; } sial_check(blk != NULL, "Attempting to update non-existent block " + id.str(sip_tables_), current_line()); #ifdef HAVE_CUDA // Lazy copying of data from gpu to host if needed. lazy_gpu_update_on_host(blk); #endif return blk; }