c++ - clEnqueueNDRangeKernel fills up entire memory -
i trying write opencl application doing memory intensive calculations. track progress of calculations created for loop creates different kernel groups. unfortunately, calculation fills whole memory. guess kernels not done executing before next heap added.
for (unsigned long i=1; i<maxglobalthreads; i+=1000000) { // calculating offset size_t temp = 1000000; size_t offset = 0; if (i>1000000) { offset = i-1000000; } cl_event tmp; clenqueuendrangekernel(command_queue, kernel, 1, &offset, &temp, null, null, 0, &tmp); // wait until threads finished (-- not working) clwaitforevents(1, &tmp); // copy results memory buffer int *res = (int*)malloc(64*sizeof(int)); int *indexnum = (int*)malloc(14*sizeof(int)); err = clenqueuereadbuffer(command_queue, foundcombimem, cl_true, 0, 64*sizeof(int), res, 0, null, null); err = clenqueuereadbuffer(command_queue, indexnummem, cl_true, 0, 14*sizeof(int), indexnum, 0, null, null); // calculate time 1000000 checked combinations diff = clock() - start; double msec = diff * 1000 / clocks_per_sec; printf("%f\n", (msec/(i*1000000))*1000000); [ ... ] }
you doing mallocs never freed on each iteration of loop. why running out of memory.
also, loop using unsigned int variable, problem depending on value of maxgloablthreads.
Comments
Post a Comment