Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gpusched_parser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
GPUSched
gpusched_parser
Commits
e6948c12
Commit
e6948c12
authored
Jun 4, 2024
by
Nordine Feddal
Browse files
Options
Downloads
Patches
Plain Diff
parse kernel global variable
parent
05ce6951
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gputask/gputask.py
+49
-12
49 additions, 12 deletions
src/gputask/gputask.py
src/main.py
+2
-2
2 additions, 2 deletions
src/main.py
with
51 additions
and
14 deletions
src/gputask/gputask.py
+
49
−
12
View file @
e6948c12
...
...
@@ -20,6 +20,7 @@ class GPUTaskParams:
# kernel can have different parameters types
# use of variadic template here to be able to handle all of them
FUNCTION
=
"
\t
void (*f)(Types...);
\n
"
;
# @TODO add here FUNCTION ARGUMENTS
### IMPL SECTION
# RT params
...
...
@@ -36,6 +37,7 @@ class GPUTaskParams:
# GENERAL params
TASK_ID_IMPL
=
"
\t
.task_id = {task_id},
\n
"
FUNCTION_IMPL
=
"
\t
.{name}=&{kernel_name},
\n
"
# @TODO add here FUNCTION ARGUMENTS
NAME_IMPL
=
"
\t
.kernel_name = std::string(
\"
{name}
\"
)
\n
"
#Parse Index
...
...
@@ -113,7 +115,8 @@ class GPUTask:
#specific parameters to retrieve the cuda kernel declarations
self
.
kfile
=
kfile
self
.
kernel_parameters_variable
=
[]
self
.
init_function_name
=
""
def
dump_str
(
self
)
->
str
:
dump
=
"
struct {struct_name} task_{no} {{
\n
"
.
format
(
struct_name
=
GPUTaskParams
.
STRUCT_NAME
,
no
=
self
.
task_id
)
...
...
@@ -137,12 +140,15 @@ class GPUTask:
return
dump
def
get_kernel_declaration
(
self
)
->
str
:
self
.
get_variables_declaration
()
print
(
self
.
kernel_parameters_variable
)
print
(
self
.
init_function_name
)
with
open
(
self
.
kfile
,
'
r
'
)
as
inFile
:
inFileLines
=
inFile
.
readlines
()
for
line
in
inFileLines
:
if
self
.
name
in
line
:
if
"
__global__
"
in
line
and
self
.
name
in
line
:
kernel_arguments
=
line
.
split
(
self
.
name
)[
1
].
strip
()
if
(
kernel_arguments
[
-
1
]
==
'
)
'
):
return
kernel_arguments
...
...
@@ -154,3 +160,34 @@ class GPUTask:
if
line
==
'
-1
\n
'
:
break
return
kernel_arguments
def
get_variables_declaration
(
self
):
parameters
=
[]
kernel_detected
=
False
parameters_detected
=
False
init_name
=
""
with
open
(
self
.
kfile
,
'
r
'
)
as
inFile
:
inFileLines
=
inFile
.
readlines
()
for
idx
,
line
in
enumerate
(
inFileLines
):
if
self
.
name
in
line
and
"
Start
"
in
line
:
kernel_detected
=
True
if
self
.
name
in
line
and
"
End
"
in
line
:
flag_kernel_detected
=
False
break
if
kernel_detected
and
"
Start Parameters
"
in
line
:
parameters_detected
=
True
elif
"
End Parameters
"
in
line
:
parameters_detected
=
False
elif
parameters_detected
and
not
line
.
isspace
():
parameters
.
append
(
line
)
if
kernel_detected
and
"
Start Init function
"
in
line
:
init_name
=
inFileLines
[
idx
+
1
]
break
for
parameter
in
parameters
:
parameter
=
(
parameter
.
split
(
"
"
)[
-
1
]).
rstrip
(
'
;
\n
'
)
self
.
kernel_parameters_variable
.
append
(
parameter
)
self
.
init_function_name
=
init_name
.
split
(
"
void
"
)[
1
].
lstrip
().
rstrip
(
"
{
\n
"
)
This diff is collapsed.
Click to expand it.
src/main.py
+
2
−
2
View file @
e6948c12
...
...
@@ -31,13 +31,13 @@ def generate_main_unroll_step():
for
job
in
range
(
0
,
currStep
.
number_kernels
):
relatedTask
=
int
(
relation_job_id_task_id
[
currStep
.
list_jobs
[
job
]],
10
)
currTask
=
list_gpu_tasks_object
[
relatedTask
]
unroll
+=
"
\t
{kernel_name}<<<{block},{thread},{smem},{stream}>>>({params});
\n
"
.
format
(
kernel_name
=
currTask
.
name
,
block
=
currTask
.
blocks
,
thread
=
currTask
.
threads
,
smem
=
currTask
.
smem
,
stream
=
"
stream_{no}
"
.
format
(
no
=
job
),
params
=
"
test
"
)
unroll
+=
"
\t
{kernel_name}<<<{block},{thread},{smem},{stream}>>>({params});
\n
"
.
format
(
kernel_name
=
currTask
.
name
,
block
=
currTask
.
blocks
,
thread
=
currTask
.
threads
,
smem
=
currTask
.
smem
,
stream
=
"
stream_{no}
"
.
format
(
no
=
job
),
params
=
"
,
"
.
join
(
currTask
.
kernel_parameters_variable
)
)
unroll
+=
"
\t
cudaDeviceSynchronize();
\n\n
"
if
i
!=
len
(
list_gpusched_step_object
)
-
1
:
unroll
+=
"
\t
step_end = high_resolution_clock::now();
\n
"
unroll
+=
"
\t
elapsed_time = step_end - base;
\n
"
unroll
+=
"
\t
elapsed_time_ms = duration_cast<ms>(elasped_time);
\n
"
unroll
+=
"
\t
idle_time = milliseconds({next_step_min_time}) - elapsed_time_ms
)
;
\n
"
.
format
(
next_step_min_time
=
list_gpusched_step_object
[
i
+
1
].
min_time_start
)
unroll
+=
"
\t
idle_time = milliseconds({next_step_min_time}) - elapsed_time_ms;
\n
"
.
format
(
next_step_min_time
=
list_gpusched_step_object
[
i
+
1
].
min_time_start
)
unroll
+=
"
\t
if (idle_time.count() > 0)
\n\t\t
std::this_thread::sleep_for(idle_time);
\n
"
...
...
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