Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hydra-image-processor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
hydra-image-processor
Commits
562b47b3
Commit
562b47b3
authored
6 years ago
by
Mark Winter
Browse files
Options
Downloads
Patches
Plain Diff
Fix so that getMinMax takes a standard ImageView<T>
parent
645a5cf7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/c/Cuda/CudaGetMinMax.cuh
+5
-2
5 additions, 2 deletions
src/c/Cuda/CudaGetMinMax.cuh
with
5 additions
and
2 deletions
src/c/Cuda/CudaGetMinMax.cuh
+
5
−
2
View file @
562b47b3
...
@@ -145,12 +145,13 @@ void cGetMinMax(CudaImageContainer<PixelType>* cudaImage, PixelType& minVal, Pix
...
@@ -145,12 +145,13 @@ void cGetMinMax(CudaImageContainer<PixelType>* cudaImage, PixelType& minVal, Pix
}
}
template
<
class
PixelType
>
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
);
cudaSetDevice
(
device
);
minVal
=
std
::
numeric_limits
<
PixelType
>::
max
();
minVal
=
std
::
numeric_limits
<
PixelType
>::
max
();
maxVal
=
std
::
numeric_limits
<
PixelType
>::
lowest
();
maxVal
=
std
::
numeric_limits
<
PixelType
>::
lowest
();
PixelType
*
deviceBuffer
=
NULL
;
PixelType
*
deviceBuffer
=
NULL
;
MinMaxMem
<
PixelType
>
minMaxMem
;
MinMaxMem
<
PixelType
>
minMaxMem
;
...
@@ -160,6 +161,8 @@ void cGetMinMax(const PixelType* imageIn, std::size_t numValues, PixelType& minV
...
@@ -160,6 +161,8 @@ void cGetMinMax(const PixelType* imageIn, std::size_t numValues, PixelType& minV
std
::
size_t
availMem
,
total
;
std
::
size_t
availMem
,
total
;
cudaMemGetInfo
(
&
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
)));
std
::
size_t
numValsPerChunk
=
MIN
(
numValues
,
(
std
::
size_t
)((
availMem
*
MAX_MEM_AVAIL
)
/
sizeof
(
PixelType
)));
int
threads
,
maxBlocks
;
int
threads
,
maxBlocks
;
minMaxMem
.
memalloc
(
numValsPerChunk
,
threads
,
maxBlocks
);
minMaxMem
.
memalloc
(
numValsPerChunk
,
threads
,
maxBlocks
);
...
@@ -169,7 +172,7 @@ void cGetMinMax(const PixelType* imageIn, std::size_t numValues, PixelType& minV
...
@@ -169,7 +172,7 @@ void cGetMinMax(const PixelType* imageIn, std::size_t numValues, PixelType& minV
{
{
std
::
size_t
curNumVals
=
MIN
(
numValsPerChunk
,
numValues
-
startIdx
);
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
));
int
blocks
=
(
int
)((
double
)
curNumVals
/
(
threads
*
2
));
std
::
size_t
sharedMemSize
=
sizeof
(
PixelType
)
*
threads
*
2
;
std
::
size_t
sharedMemSize
=
sizeof
(
PixelType
)
*
threads
*
2
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment