Skip to content
Snippets Groups Projects
Commit 562b47b3 authored by Mark Winter's avatar Mark Winter
Browse files

Fix so that getMinMax takes a standard ImageView<T>

parent 645a5cf7
No related branches found
No related tags found
No related merge requests found
......@@ -145,12 +145,13 @@ void cGetMinMax(CudaImageContainer<PixelType>* cudaImage, PixelType& minVal, Pix
}
template <class PixelType>
void cGetMinMax(const PixelType* imageIn, std::size_t numValues, PixelType& minVal, PixelType& maxVal, int device = 0)
void cGetMinMax(ImageView<PixelType> imageIn, PixelType& minVal, PixelType& maxVal, int device = 0)
{
cudaSetDevice(device);
minVal = std::numeric_limits<PixelType>::max();
maxVal = std::numeric_limits<PixelType>::lowest();
PixelType* deviceBuffer = NULL;
MinMaxMem<PixelType> minMaxMem;
......@@ -160,6 +161,8 @@ void cGetMinMax(const PixelType* imageIn, std::size_t numValues, PixelType& minV
std::size_t availMem, total;
cudaMemGetInfo(&availMem, &total);
std::size_t numValues = imageIn.getNumElements();
std::size_t numValsPerChunk = MIN(numValues, (std::size_t)((availMem*MAX_MEM_AVAIL) / sizeof(PixelType)));
int threads, maxBlocks;
minMaxMem.memalloc(numValsPerChunk, threads, maxBlocks);
......@@ -169,7 +172,7 @@ void cGetMinMax(const PixelType* imageIn, std::size_t numValues, PixelType& minV
{
std::size_t curNumVals = MIN(numValsPerChunk, numValues - startIdx);
HANDLE_ERROR(cudaMemcpy(deviceBuffer, imageIn + startIdx, sizeof(PixelType)*curNumVals, cudaMemcpyHostToDevice));
HANDLE_ERROR(cudaMemcpy(deviceBuffer, imageIn.getConstPtr() + startIdx, sizeof(PixelType)*curNumVals, cudaMemcpyHostToDevice));
int blocks = (int)((double)curNumVals / (threads * 2));
std::size_t sharedMemSize = sizeof(PixelType)*threads * 2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment