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
f8da1715
Commit
f8da1715
authored
Feb 5, 2024
by
Jammer, Tim
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring: set_has_error into base class
parent
8fb97451
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
+13
-6
13 additions, 6 deletions
scripts/Infrastructure/AllocCall.py
scripts/Infrastructure/Instruction.py
+9
-1
9 additions, 1 deletion
scripts/Infrastructure/Instruction.py
scripts/Infrastructure/MPICall.py
+1
-3
1 addition, 3 deletions
scripts/Infrastructure/MPICall.py
with
23 additions
and
10 deletions
scripts/Infrastructure/AllocCall.py
+
13
−
6
View file @
f8da1715
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
from
typing_extensions
import
override
from
typing_extensions
import
override
from
scripts.Infrastructure.Instruction
import
Instruction
from
scripts.Infrastructure.Instruction
import
Instruction
from
scripts.Infrastructure.Variables
import
ERROR_MARKER_COMMENT
alloc_template
=
"""
alloc_template
=
"""
@{TYPE}@* @{NAME}@ = (@{TYPE}@*) @{FUNCTION}@(@{NUM}@ @{SEP}@ sizeof(@{TYPE}@));
@{TYPE}@* @{NAME}@ = (@{TYPE}@*) @{FUNCTION}@(@{NUM}@ @{SEP}@ sizeof(@{TYPE}@));
...
@@ -34,6 +35,7 @@ class AllocCall(Instruction):
...
@@ -34,6 +35,7 @@ class AllocCall(Instruction):
name: name of buffer variable
name: name of buffer variable
use_malloc: True: use Malloc, False: use calloc for allocation
use_malloc: True: use Malloc, False: use calloc for allocation
"""
"""
super
().
__init__
(
""
)
self
.
_use_malloc
=
use_malloc
self
.
_use_malloc
=
use_malloc
self
.
_type
=
type
self
.
_type
=
type
self
.
_num_elements
=
num_elements
self
.
_num_elements
=
num_elements
...
@@ -48,13 +50,18 @@ class AllocCall(Instruction):
...
@@ -48,13 +50,18 @@ class AllocCall(Instruction):
delim
=
'
,
'
delim
=
'
,
'
func
=
"
calloc
"
func
=
"
calloc
"
return
(
alloc_template
s
=
(
alloc_template
.
replace
(
"
@{NAME}@
"
,
self
.
_name
)
.
replace
(
"
@{NAME}@
"
,
self
.
_name
)
.
replace
(
"
@{TYPE}@
"
,
self
.
_type
)
.
replace
(
"
@{TYPE}@
"
,
self
.
_type
)
.
replace
(
"
@{FUNCTION}@
"
,
func
)
.
replace
(
"
@{FUNCTION}@
"
,
func
)
.
replace
(
"
@{NUM}@
"
,
str
(
self
.
_num_elements
))
.
replace
(
"
@{NUM}@
"
,
str
(
self
.
_num_elements
))
.
replace
(
"
@{SEP}@
"
,
delim
))
.
replace
(
"
@{SEP}@
"
,
delim
))
if
self
.
_has_error
:
s
+=
ERROR_MARKER_COMMENT
return
s
def
set_num_elements
(
self
,
num_elements
:
int
):
def
set_num_elements
(
self
,
num_elements
:
int
):
self
.
_num_elements
=
num_elements
self
.
_num_elements
=
num_elements
...
...
This diff is collapsed.
Click to expand it.
scripts/Infrastructure/Instruction.py
+
9
−
1
View file @
f8da1715
#! /usr/bin/python3
#! /usr/bin/python3
from
scripts.Infrastructure.Variables
import
ERROR_MARKER_COMMENT
class
Instruction
(
object
):
class
Instruction
(
object
):
...
@@ -8,6 +9,13 @@ class Instruction(object):
...
@@ -8,6 +9,13 @@ class Instruction(object):
def
__init__
(
self
,
str_representation
):
def
__init__
(
self
,
str_representation
):
self
.
_str_representation
=
str_representation
self
.
_str_representation
=
str_representation
self
.
_has_error
=
False
def
set_has_error
(
self
,
has_error
:
bool
=
True
):
self
.
_has_error
=
has_error
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
_str_representation
+
"
\n
"
if
self
.
_has_error
:
return
self
.
_str_representation
+
ERROR_MARKER_COMMENT
else
:
return
self
.
_str_representation
This diff is collapsed.
Click to expand it.
scripts/Infrastructure/MPICall.py
+
1
−
3
View file @
f8da1715
...
@@ -10,6 +10,7 @@ class MPI_Call(Instruction):
...
@@ -10,6 +10,7 @@ class MPI_Call(Instruction):
@override
@override
def
__init__
(
self
,
function
:
str
,
args
:
typing
.
OrderedDict
[
str
,
str
],
version
:
str
):
def
__init__
(
self
,
function
:
str
,
args
:
typing
.
OrderedDict
[
str
,
str
],
version
:
str
):
super
().
__init__
(
""
)
self
.
_function
=
function
self
.
_function
=
function
self
.
_args
=
args
self
.
_args
=
args
self
.
_version
=
version
self
.
_version
=
version
...
@@ -37,6 +38,3 @@ class MPI_Call(Instruction):
...
@@ -37,6 +38,3 @@ class MPI_Call(Instruction):
def
get_version
(
self
)
->
str
:
def
get_version
(
self
)
->
str
:
return
self
.
_version
return
self
.
_version
def
set_has_error
(
self
,
has_error
:
bool
=
True
):
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