Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MPI-BugBench
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
High Performance Computing - Public
MPI-BugBench
Commits
6bf6c245
Commit
6bf6c245
authored
1 year ago
by
Jammer, Tim
Browse files
Options
Downloads
Patches
Plain Diff
added Type hints (
#7
) for the Instruction Classes
parent
92f7fa9c
No related branches found
No related tags found
1 merge request
!9
Infrastructure: Type Hints, Instruction class and lists of instructions
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
scripts/Infrastructure/AllocCall.py
+11
-11
11 additions, 11 deletions
scripts/Infrastructure/AllocCall.py
scripts/Infrastructure/Instruction.py
+1
-1
1 addition, 1 deletion
scripts/Infrastructure/Instruction.py
scripts/Infrastructure/MPICall.py
+7
-7
7 additions, 7 deletions
scripts/Infrastructure/MPICall.py
with
19 additions
and
19 deletions
scripts/Infrastructure/AllocCall.py
+
11
−
11
View file @
6bf6c245
...
@@ -24,7 +24,7 @@ alloc_template = """
...
@@ -24,7 +24,7 @@ alloc_template = """
class
AllocCall
(
Instruction
):
class
AllocCall
(
Instruction
):
@override
@override
def
__init__
(
self
,
type
,
num_elements
,
name
=
"
buf
"
,
use_malloc
=
False
):
def
__init__
(
self
,
type
:
str
,
num_elements
:
int
,
name
:
str
=
"
buf
"
,
use_malloc
:
bool
=
False
):
"""
"""
Creates a New allocation Call
Creates a New allocation Call
...
@@ -55,13 +55,13 @@ class AllocCall (Instruction):
...
@@ -55,13 +55,13 @@ class AllocCall (Instruction):
.
replace
(
"
@{NUM}@
"
,
str
(
self
.
_num_elements
))
.
replace
(
"
@{NUM}@
"
,
str
(
self
.
_num_elements
))
.
replace
(
"
@{SEP}@
"
,
delim
))
.
replace
(
"
@{SEP}@
"
,
delim
))
def
set_num_elements
(
self
,
num_elements
):
def
set_num_elements
(
self
,
num_elements
:
int
):
self
.
_num_elements
=
num_elements
self
.
_num_elements
=
num_elements
def
set_name
(
self
,
name
):
def
set_name
(
self
,
name
:
str
):
self
.
_name
=
name
self
.
_name
=
name
def
set_type
(
self
,
type
):
def
set_type
(
self
,
type
:
str
):
self
.
_type
=
type
self
.
_type
=
type
def
set_use_malloc
(
self
):
def
set_use_malloc
(
self
):
...
@@ -70,19 +70,19 @@ class AllocCall (Instruction):
...
@@ -70,19 +70,19 @@ class AllocCall (Instruction):
def
set_use_calloc
(
self
):
def
set_use_calloc
(
self
):
self
.
_use_malloc
=
False
self
.
_use_malloc
=
False
def
get_num_elements
(
self
):
def
get_num_elements
(
self
)
->
int
:
return
self
.
_num_elements
return
self
.
_num_elements
def
get_name
(
self
):
def
get_name
(
self
)
->
str
:
return
self
.
_name
return
self
.
_name
def
get_type
(
self
):
def
get_type
(
self
)
->
str
:
return
self
.
_type
return
self
.
_type
def
get_use_malloc
(
self
):
def
get_use_malloc
(
self
)
->
bool
:
return
self
.
_use_malloc
return
self
.
_use_malloc
def
get_free
(
alloc_call
)
:
def
get_free
(
alloc_call
:
AllocCall
)
->
Instruction
:
assert
isinstance
(
alloc_call
,
AllocCall
)
assert
isinstance
(
alloc_call
,
AllocCall
)
return
"
free(
"
+
alloc_call
.
get_name
()
+
"
);
\n
"
return
Instruction
(
"
free(
"
+
alloc_call
.
get_name
()
+
"
);
"
)
This diff is collapsed.
Click to expand it.
scripts/Infrastructure/Instruction.py
+
1
−
1
View file @
6bf6c245
...
@@ -10,4 +10,4 @@ class Instruction(object):
...
@@ -10,4 +10,4 @@ class Instruction(object):
self
.
_str_representation
=
str_representation
self
.
_str_representation
=
str_representation
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
_str_representation
return
self
.
_str_representation
+
"
\n
"
This diff is collapsed.
Click to expand it.
scripts/Infrastructure/MPICall.py
+
7
−
7
View file @
6bf6c245
#! /usr/bin/python3
#! /usr/bin/python3
import
typing
from
typing_extensions
import
override
from
typing_extensions
import
override
from
scripts.Infrastructure.Instruction
import
Instruction
from
scripts.Infrastructure.Instruction
import
Instruction
...
@@ -8,7 +9,7 @@ from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT
...
@@ -8,7 +9,7 @@ from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT
class
MPI_Call
(
Instruction
):
class
MPI_Call
(
Instruction
):
@override
@override
def
__init__
(
self
,
function
,
args
,
version
):
def
__init__
(
self
,
function
:
str
,
args
:
typing
.
OrderedDict
[
str
,
str
]
,
version
:
str
):
self
.
_function
=
function
self
.
_function
=
function
self
.
_args
=
args
self
.
_args
=
args
self
.
_version
=
version
self
.
_version
=
version
...
@@ -27,16 +28,15 @@ class MPI_Call (Instruction):
...
@@ -27,16 +28,15 @@ class MPI_Call (Instruction):
return
s
return
s
def
set_arg
(
self
,
arg
,
value
):
def
set_arg
(
self
,
arg
:
str
,
value
:
str
):
assert
self
.
has_arg
(
arg
)
assert
self
.
has_arg
(
arg
)
self
.
_args
[
arg
]
=
value
self
.
_args
[
arg
]
=
value
def
has_arg
(
self
,
arg
)
:
def
has_arg
(
self
,
arg
:
str
)
->
bool
:
return
arg
in
self
.
_args
return
arg
in
self
.
_args
def
get_version
(
self
):
def
get_version
(
self
)
->
str
:
return
self
.
_version
return
self
.
_version
def
set_has_error
(
self
,
has_error
=
True
):
def
set_has_error
(
self
,
has_error
:
bool
=
True
):
self
.
_has_error
=
has_error
self
.
_has_error
=
has_error
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