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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
hydra-image-processor
Commits
fdc3aa4e
Commit
fdc3aa4e
authored
5 years ago
by
Mark Winter
Browse files
Options
Downloads
Patches
Plain Diff
Support dynamic enabling of scoped process mutex
parent
a30db92d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/c/ScriptCmds/ScriptCommandImpl.h
+63
-41
63 additions, 41 deletions
src/c/ScriptCmds/ScriptCommandImpl.h
with
63 additions
and
41 deletions
src/c/ScriptCmds/ScriptCommandImpl.h
+
63
−
41
View file @
fdc3aa4e
...
...
@@ -6,6 +6,8 @@
#include
"ScriptCommand.h"
#include
"ScopedProcessMutex.h"
#include
"HydraConfig.h"
#include
"mph/tuple_helpers.h"
template
<
typename
Derived
,
typename
ConverterType
>
...
...
@@ -169,63 +171,32 @@ private:
template
<
typename
...
Args
,
size_t
...
Is
>
static
void
exec_dispatch_impl
(
std
::
tuple
<
Args
...
>
ioArgs
,
mph
::
index_sequence
<
Is
...
>
)
{
// TODO: MRW - Should all execute() routines dispatch through SCOPED_PROCESS_MUTEX since it can be disabled now?
Derived
::
execute
(
std
::
forward
<
Args
>
(
std
::
get
<
Is
>
(
ioArgs
))...);
}
private
:
/////////////////////////
// execute - (Static-overloadable)
// Default execute function dispatches to image-type templated
// process<OutT,InT>(Args...) function
//
// NOTE: Main purpose of default execute() is to check config and
// dispatch to exec_internal()
/////////////////////////
template
<
typename
...
Args
>
static
void
execute
(
Args
&&
...
args
)
{
if
(
HydraConfig
::
useProcessMutex
()
)
{
// Use a scoped process-level mutex to run only a single GPU kernel at a time
// TODO: Figure out a scheduling system multi-process HIP calls
// TODO: Figure out a scheduling system
for
multi-process HIP calls
SCOPED_PROCESS_MUTEX
(
hip_cmd_gpu_
);
static_assert
(
ArgConverter
::
has_deferred_image_inputs
(),
"HIP_COMPILE: Argument layout has no dynamic image inputs. Please overload default ::execute() function!"
);
Script
::
IdType
type
=
ArgConverter
::
getInputType
(
std
::
forward
<
Args
>
(
args
)...);
if
(
type
==
Script
::
TypeToIdMap
<
bool
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
bool
>,
bool
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
uint8_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
uint8_t
>,
uint8_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
uint16_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
uint16_t
>,
uint16_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
int16_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
int16_t
>,
int16_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
uint32_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
uint32_t
>,
uint32_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
int32_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
int32_t
>,
int32_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
float
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
float
>,
float
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
double
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
double
>,
double
>
(
std
::
forward
<
Args
>
(
args
)...);
Derived
::
exec_internal
(
std
::
forward
<
Args
>
(
args
)...);
}
else
{
throw
ArgError
(
"Image type unsupported (%x)"
,
type
);
Derived
::
exec_internal
(
std
::
forward
<
Args
>
(
args
)...
);
}
}
...
...
@@ -274,6 +245,57 @@ private:
ArgConverter
::
convertSelected
(
argPtrs
,
convertedPtrs
,
DeferredOutSel
{});
}
/////////////////////////
// exec_internal - (Not overloadable)
// Dispatch to processing function:
// process<OutT,inT>()
/////////////////////////
template
<
typename
...
Args
>
static
void
exec_internal
(
Args
&&
...
args
)
{
static_assert
(
ArgConverter
::
has_deferred_image_inputs
(),
"HIP_COMPILE: Argument layout has no dynamic image inputs. Please overload default ::execute() function!"
);
Script
::
IdType
type
=
ArgConverter
::
getInputType
(
std
::
forward
<
Args
>
(
args
)...);
if
(
type
==
Script
::
TypeToIdMap
<
bool
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
bool
>,
bool
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
uint8_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
uint8_t
>,
uint8_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
uint16_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
uint16_t
>,
uint16_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
int16_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
int16_t
>,
int16_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
uint32_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
uint32_t
>,
uint32_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
int32_t
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
int32_t
>,
int32_t
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
float
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
float
>,
float
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
type
==
Script
::
TypeToIdMap
<
double
>::
typeId
)
{
Derived
::
template
process
<
OutMap
<
double
>,
double
>
(
std
::
forward
<
Args
>
(
args
)...);
}
else
{
throw
ArgError
(
"Image type unsupported (%x)"
,
type
);
}
}
template
<
typename
...
Args
>
static
void
run_dispatch
(
std
::
tuple
<
Args
...
>
runArgs
)
{
...
...
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