void BlockManager::lazy_gpu_update_on_host(const Block::BlockPtr& blk) { if (!blk->is_on_gpu() && !blk->is_on_host()) { fail("block allocated neither on host or gpu", current_line()); } else if (!blk->is_on_host()) { blk->allocate_host_data(); _gpu_device_to_host(blk->get_data(), blk->get_gpu_data(), blk->size()); } else if (blk->is_dirty_on_gpu()) { _gpu_device_to_host(blk->get_data(), blk->get_gpu_data(), blk->size()); } else if (blk->is_dirty_on_all()) { fail("block dirty on host & gpu !", current_line()); } blk->set_on_host(); blk->unset_dirty_on_gpu(); blk->set_dirty_on_host(); }
void BlockManager::lazy_gpu_write_on_host(Block::BlockPtr& blk, const BlockId &id, const BlockShape& shape) { if (!blk->is_on_gpu() && !blk->is_on_host()) { block_map_.cached_delete_block(id); // Get rid of block, create a new one blk = create_block(id, shape); // if (is_scope_extent) { // temp_block_list_stack_.back()->push_back(id); // } } else if (!blk->is_on_host()) { blk->allocate_host_data(); _gpu_device_to_host(blk->get_data(), blk->get_gpu_data(), blk->size()); } else if (blk->is_dirty_on_gpu()) { _gpu_device_to_host(blk->get_data(), blk->get_gpu_data(), blk->size()); } else if (blk->is_dirty_on_all()) { fail("block dirty on host & gpu !", current_line()); } blk->set_on_host(); blk->set_dirty_on_host(); blk->unset_dirty_on_gpu(); }