Skip to content

Commit

Permalink
changes sparse gray fetch interface slightly; verifies output
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Plaza committed May 25, 2015
1 parent 6a4f1c5 commit 3ab95ea
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
8 changes: 4 additions & 4 deletions libdvid/DVIDThreadedFetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ namespace libdvid {
* \param service name of dvid node service
* \param labelvol_name name of label volume with body id
* \param grayscale_name name of grayscale data instance
* \param use_blocks if true uses block interface instead of raw ND
* \param num_threads number of threads used in the fetch.
* \param use_blocks if true uses block interface instead of raw ND
* \param request_efficiency how requests are packaged (0: 1 at a time, 1: X contig)
* \return grayscale blocks in X,Y,Z order of the body blocks
* \return array of blocks matrix order (X = column, Y = row, Z=slice)
*/
GrayscaleBlocks get_body_blocks(DVIDNodeService& service,
std::vector<BinaryDataPtr> get_body_blocks(DVIDNodeService& service,
std::string labelvol_name, std::string grayscale_name, uint64 bodyid,
bool use_blocks = false, int num_threads = 1,
int num_threads = 1, bool use_blocks = false,
int request_efficiency = 1);


Expand Down
30 changes: 26 additions & 4 deletions load_tests/loadtest_sparsegray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,41 @@ int main(int argc, char** argv)

// create DVID node accessor
libdvid::DVIDNodeService dvid_node(argv[1], argv[2]);

vector<libdvid::BinaryDataPtr> blocks;
vector<libdvid::BinaryDataPtr> blocks2;
vector<libdvid::BinaryDataPtr> blocks3;
// slightly bogus test because the cache will be warmed up

{
// call using the ND raw
ScopeTime overall_time;
libdvid::GrayscaleBlocks blocks = libdvid::get_body_blocks(dvid_node, argv[3], argv[4], atoi(argv[5]), false, 1, 1);
blocks = libdvid::get_body_blocks(dvid_node, argv[3], argv[4], atoi(argv[5]), 1, false, 1);
}

{
// call using blocks
ScopeTime overall_time;
blocks2 = libdvid::get_body_blocks(dvid_node, argv[3], argv[4], atoi(argv[5]), 1, true, 1);
}

{
ScopeTime overall_time;
// call doing one request at a time
libdvid::GrayscaleBlocks blocks = libdvid::get_body_blocks(dvid_node, argv[3], argv[4], atoi(argv[5]), false, 1, 0);
blocks3 = libdvid::get_body_blocks(dvid_node, argv[3], argv[4], atoi(argv[5]), 1, false, 0);
}

assert(blocks.size() == blocks2.size());
assert(blocks2.size() == blocks3.size());

for (unsigned int i = 0; i < blocks.size(); ++i) {
const unsigned char* raw1 = blocks[i]->get_raw();
const unsigned char* raw2 = blocks2[i]->get_raw();
const unsigned char* raw3 = blocks3[i]->get_raw();
for (unsigned int j = 0; j < libdvid::DEFBLOCKSIZE*
libdvid::DEFBLOCKSIZE*libdvid::DEFBLOCKSIZE; ++j) {
assert(*raw1 == *raw2);
assert(*raw2 == *raw3);
++raw1; ++raw2; ++raw3;
}
}

return 0;
Expand Down
16 changes: 9 additions & 7 deletions src/DVIDThreadedFetch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ static const int MAX_BLOCKS = 4096;

namespace libdvid {

GrayscaleBlocks get_body_blocks(DVIDNodeService& service, string labelvol_name,
string grayscale_name, uint64 bodyid, bool use_blocks, int num_threads,
int request_efficiency)
vector<BinaryDataPtr> get_body_blocks(DVIDNodeService& service, string labelvol_name,
string grayscale_name, uint64 bodyid, int num_threads,
bool use_blocks, int request_efficiency)
{
vector<BlockXYZ> blockcoords;

Expand All @@ -24,7 +24,7 @@ GrayscaleBlocks get_body_blocks(DVIDNodeService& service, string labelvol_name,

int num_requests = 0;

GrayscaleBlocks blocks;
vector<BinaryDataPtr> blocks;

uint8* blockdata = 0;
if ((request_efficiency == 1) && !use_blocks) {
Expand Down Expand Up @@ -73,7 +73,8 @@ GrayscaleBlocks get_body_blocks(DVIDNodeService& service, string labelvol_name,
block_coords.push_back(z);
GrayscaleBlocks blocks2 = service.get_grayblocks(grayscale_name, block_coords, curr_runlength);
for (int j = 0; j < curr_runlength; ++j) {
blocks.push_back(blocks2[j]);
BinaryDataPtr ptr = BinaryData::create_binary_data((const char*)blocks2[j], DEFBLOCKSIZE*DEFBLOCKSIZE*DEFBLOCKSIZE);
blocks.push_back(ptr);
}
} else {
Dims_t dims;
Expand All @@ -90,7 +91,7 @@ GrayscaleBlocks get_body_blocks(DVIDNodeService& service, string labelvol_name,

if (curr_runlength == 1) {
// do a simple copy for just one block
blocks.push_back(grayvol.get_raw());
blocks.push_back(grayvol.get_binary());
} else {
const uint8* raw_data = grayvol.get_raw();

Expand All @@ -113,7 +114,8 @@ GrayscaleBlocks get_body_blocks(DVIDNodeService& service, string labelvol_name,
data_iter += ((offsety) - DEFBLOCKSIZE);
}
}
blocks.push_back(blockdata);
BinaryDataPtr ptr = BinaryData::create_binary_data((const char*) blockdata, DEFBLOCKSIZE*DEFBLOCKSIZE*DEFBLOCKSIZE);
blocks.push_back(ptr);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions todo
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


-add more correct-by-compilation
-improve test coverage

Expand Down

0 comments on commit 3ab95ea

Please sign in to comment.