Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pairs
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
software
pairs
Commits
ae45fc9b
Commit
ae45fc9b
authored
3 years ago
by
Rafael Ravedutti
Browse files
Options
Downloads
Patches
Plain Diff
Add first (almost) working version with runtime
Signed-off-by:
Rafael Ravedutti
<
rafaelravedutti@gmail.com
>
parent
75bf109d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
code_gen/cgen.py
+11
-1
11 additions, 1 deletion
code_gen/cgen.py
ir/properties.py
+6
-1
6 additions, 1 deletion
ir/properties.py
runtime/read_from_file.hpp
+3
-3
3 additions, 3 deletions
runtime/read_from_file.hpp
sim/properties.py
+6
-4
6 additions, 4 deletions
sim/properties.py
with
26 additions
and
9 deletions
code_gen/cgen.py
+
11
−
1
View file @
ae45fc9b
...
...
@@ -6,6 +6,7 @@ from ir.cast import Cast
from
ir.bin_op
import
BinOp
,
BinOpDef
from
ir.data_types
import
Type_Int
,
Type_Float
,
Type_String
,
Type_Vector
from
ir.functions
import
Call
from
ir.layouts
import
Layout_AoS
,
Layout_SoA
,
Layout_Invalid
from
ir.lit
import
Lit
from
ir.loops
import
For
,
Iter
,
ParticleFor
,
While
from
ir.math
import
Sqrt
...
...
@@ -160,7 +161,16 @@ class CGen:
"
Prop_Invalid
"
assert
ptype
!=
"
Prop_Invalid
"
,
"
Invalid property type!
"
self
.
print
(
f
"
ps->addProperty(Property(
{
p
.
id
()
}
,
\"
{
p
.
name
()
}
\"
,
{
p
.
name
()
}
,
{
ptype
}
));
"
)
playout
=
"
AoS
"
if
p
.
layout
()
==
Layout_AoS
else
\
"
SoA
"
if
p
.
layout
()
==
Layout_SoA
else
\
"
Invalid
"
if
p
.
type
()
!=
Type_Vector
or
p
.
layout
()
==
Layout_Invalid
:
self
.
print
(
f
"
ps->addProperty(Property(
{
p
.
id
()
}
,
\"
{
p
.
name
()
}
\"
,
{
p
.
name
()
}
,
{
ptype
}
));
"
)
else
:
sizes
=
"
,
"
.
join
([
str
(
self
.
generate_expression
(
size
))
for
size
in
ast_node
.
sizes
()])
self
.
print
(
f
"
ps->addProperty(Property(
{
p
.
id
()
}
,
\"
{
p
.
name
()
}
\"
,
{
p
.
name
()
}
,
{
ptype
}
,
{
playout
}
,
{
sizes
}
));
"
)
if
isinstance
(
ast_node
,
Timestep
):
self
.
generate_statement
(
ast_node
.
block
)
...
...
This diff is collapsed.
Click to expand it.
ir/properties.py
+
6
−
1
View file @
ae45fc9b
from
ir.ast_node
import
ASTNode
from
ir.layouts
import
Layout_AoS
from
ir.lit
import
as_lit_ast
class
Properties
:
...
...
@@ -100,13 +101,17 @@ class PropertyList(ASTNode):
class
RegisterProperty
(
ASTNode
):
def
__init__
(
self
,
sim
,
prop
):
def
__init__
(
self
,
sim
,
prop
,
sizes
):
super
().
__init__
(
sim
)
self
.
prop
=
prop
self
.
sizes_list
=
[
as_lit_ast
(
sim
,
s
)
for
s
in
sizes
]
self
.
sim
.
add_statement
(
self
)
def
property
(
self
):
return
self
.
prop
def
sizes
(
self
):
return
self
.
sizes_list
def
__str__
(
self
):
return
f
"
Property<
{
self
.
prop
.
name
()
}
>
"
This diff is collapsed.
Click to expand it.
runtime/read_from_file.hpp
+
3
−
3
View file @
ae45fc9b
...
...
@@ -16,7 +16,7 @@ size_t read_particle_data(PairsSim *ps, const char *filename, double *grid_buffe
int
read_grid_data
=
0
;
if
(
in_file
.
is_open
())
{
while
(
getline
(
in_file
,
line
))
{
while
(
std
::
getline
(
in_file
,
line
))
{
std
::
stringstream
line_stream
(
line
);
std
::
string
in0
;
int
i
=
0
;
...
...
@@ -25,7 +25,6 @@ size_t read_particle_data(PairsSim *ps, const char *filename, double *grid_buffe
if
(
!
read_grid_data
)
{
PAIRS_ASSERT
(
i
<
ps
->
getNumDims
()
*
2
);
grid_buffer
[
i
]
=
std
::
stod
(
in0
);
read_grid_data
=
1
;
}
else
{
PAIRS_ASSERT
(
i
<
nprops
);
property_t
p_id
=
properties
[
i
];
...
...
@@ -55,7 +54,8 @@ size_t read_particle_data(PairsSim *ps, const char *filename, double *grid_buffe
i
++
;
}
n
++
;
n
+=
(
read_grid_data
)
?
1
:
0
;
read_grid_data
=
1
;
}
in_file
.
close
();
...
...
This diff is collapsed.
Click to expand it.
sim/properties.py
+
6
−
4
View file @
ae45fc9b
from
functools
import
reduce
from
ir.data_types
import
Type_Float
,
Type_Vector
from
ir.loops
import
ParticleFor
from
ir.memory
import
Malloc
,
Realloc
from
ir.properties
import
RegisterProperty
from
ir.utils
import
Print
import
operator
class
PropertiesAlloc
:
...
...
@@ -19,15 +21,15 @@ class PropertiesAlloc:
if
p
.
type
()
==
Type_Float
:
sizes
=
[
capacity
]
elif
p
.
type
()
==
Type_Vector
:
sizes
=
[
capacity
*
self
.
sim
.
ndims
()]
sizes
=
[
capacity
,
self
.
sim
.
ndims
()]
else
:
raise
Exception
(
"
Invalid property type!
"
)
if
self
.
realloc
:
Realloc
(
self
.
sim
,
p
,
sizes
)
Realloc
(
self
.
sim
,
p
,
reduce
(
operator
.
mul
,
sizes
)
)
else
:
Malloc
(
self
.
sim
,
p
,
sizes
,
True
)
RegisterProperty
(
self
.
sim
,
p
)
Malloc
(
self
.
sim
,
p
,
reduce
(
operator
.
mul
,
sizes
)
,
True
)
RegisterProperty
(
self
.
sim
,
p
,
sizes
)
return
self
.
sim
.
block
...
...
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