// allocate a stack to store the devices that have been pushed
constintstackSize=20;
staticintcurStack=0;
staticsize_tdeviceStack[stackSize]={0};
// memory allocation
void*mallocbytes(size_tnelem,size_tsz)
{
for(size_tretry=0;;retry++)
{
try
{
//fprintf (stderr, "mallocbytes: allocating %d elements of size %d, %d bytes\n", (int) nelem, (int) sz, (int) (nelem * sz)); // comment out by [v-hansu] to get rid out annoying output
void*p;
cudaMalloc(&p,nelem*sz)||"cudaMalloc failed";
returnp;
}
catch(conststd::exception&e)
{
fprintf(stderr,"mallocbytes: failed with error %s\n",e.what());