I have a fairly standard loop for reading in from a file in binary:
char* buffer;
if(imageData.is_open())
{
imageData.seekg(0, std::ios::end);
int filelen = imageData.tellg();
entrysize = filelen/(hdrDimensions[0] * hdrDimensions[1] * hdrDimensions[2] * hdrDimensions[3]);
buffer = new char[sizeof(short int)];
if(entrysize == 2)
{
imgDataShort = new std::vector<short int>((hdrDimensions[0] * hdrDimensions[1] * hdrDimensions[2] * hdrDimensions[3]), 0);
imageData.seekg(0, std::ios::beg);
int j(0);
for(int i=0; i < (hdrDimensions[0] * hdrDimensions[1] * hdrDimensions[2] * hdrDimensions[3]); i++)
{
imageData.read(reinterpret_cast<char*>(buffer), sizeof(short int));
memcpy(&(imgDataShort->at(i)), buffer, sizeof(short int));
j += sizeof(short int);
}
}
delete [] buffer;
}
in this case, reading a CT image. I have come across a strange problem whereby this loop hangs about halfway through the file (the file is 30MB), going into disk sleep. I have absolutely no idea why this is happening.
Details:
Just in case it is important, I'm running this on an Intel XeonPhi card which is running busybox, and the file is being read from an nfs mount. The exact same code runs fine on a 'normal' machine. I have no control over the nfs configuration, but if something is broken, obviously I can ask for it to be fixed. The mount config line looks like (taken from df -h):
rw,relatime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=XXX.XXX.XXX.XXX,mountvers=3,mountport=300,mountproto=udp,local_lock=none,addr=XXX.XXX.XXX.XXX