int main() { STXXL_MSG(sizeof(MyType) << " " << (BLOCK_SIZE % sizeof(MyType))); STXXL_MSG(sizeof(block_type) << " " << BLOCK_SIZE); const unsigned nblocks = 2; stxxl::BIDArray<BLOCK_SIZE> bids(nblocks); std::vector<int> disks(nblocks, 2); stxxl::request_ptr* reqs = new stxxl::request_ptr[nblocks]; stxxl::block_manager* bm = stxxl::block_manager::get_instance(); bm->new_blocks(stxxl::striping(), bids.begin(), bids.end()); block_type* block = new block_type[2]; STXXL_MSG(std::hex); STXXL_MSG("Allocated block address : " << (stxxl::unsigned_type)(block)); STXXL_MSG("Allocated block address + 1: " << (stxxl::unsigned_type)(block + 1)); STXXL_MSG(std::dec); unsigned i = 0; for (i = 0; i < block_type::size; ++i) { block->elem[i].integer = i; //memcpy (block->elem[i].chars, "STXXL", 4); } for (i = 0; i < nblocks; ++i) reqs[i] = block->write(bids[i], my_handler()); std::cout << "Waiting " << std::endl; stxxl::wait_all(reqs, nblocks); for (i = 0; i < nblocks; ++i) { reqs[i] = block->read(bids[i], my_handler()); reqs[i]->wait(); for (int j = 0; j < block_type::size; ++j) { STXXL_CHECK2(j == block->elem[j].integer, "Error in block " << std::hex << i << " pos: " << j << " value read: " << block->elem[j].integer); } } bm->delete_blocks(bids.begin(), bids.end()); delete[] reqs; delete[] block; #if 0 // variable-size blocks, not supported currently BIDArray<0> vbids(nblocks); for (i = 0; i < nblocks; i++) vbids[i].size = 1024 + i; bm->new_blocks(striping(), vbids.begin(), vbids.end()); for (i = 0; i < nblocks; i++) STXXL_MSG("Allocated block: offset=" << vbids[i].offset << ", size=" << vbids[i].size); bm->delete_blocks(vbids.begin(), vbids.end()); #endif }
char * gfs_client_rep_transfer_state_alloc(file_offset_t file_size, int algorithm_version, int ndivisions, int interleave_factor, struct gfs_client_rep_transfer_state ***transfersp) { int i; struct gfs_client_rep_transfer_state **transfers; if (algorithm_version != GFS_CLIENT_REP_ALGORITHM_LATEST) return ("unknown gfrep algorithm"); transfers = malloc(sizeof(*transfers) * ndivisions); if (transfers == NULL) return (GFARM_ERR_NO_MEMORY); for (i = 0; i < ndivisions; i++) { transfers[i] = malloc(sizeof(*transfers[i])); if (transfers[i] == NULL) { while (--i >= 0) free(transfers[i]); free(transfers); return (GFARM_ERR_NO_MEMORY); } } if (interleave_factor == 0) { simple_division(file_size, ndivisions, transfers); } else { striping(file_size, ndivisions, interleave_factor, transfers); } *transfersp = transfers; return (NULL); }