added operators to the interpreter. storing result still missing
Some checks failed
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Has been cancelled

This commit is contained in:
Daniel 2024-08-08 12:06:42 +02:00
parent f1f8c3b2a4
commit 62d10845e9
5 changed files with 195 additions and 79 deletions

View File

@ -5,9 +5,9 @@ Input:
- Matrix for the variables of the expression (x1..xn) ```variables::Matrix{Float64}``` - Matrix for the variables of the expression (x1..xn) ```variables::Matrix{Float64}```
- Vector of Vectors for the parameters of the expression (p1..pn) ```parameters::Vector{Vector{Float64}}``` - Vector of Vectors for the parameters of the expression (p1..pn) ```parameters::Vector{Vector{Float64}}```
All expressions have to have the same number of variables. They do not need to appear in the same spot, they only need to be labled x1 through xn. However, they can have a different number of parameters. These can also appear at any given point and must be labled p1 through pn. All expressions have to have the same number of variables. They do not need to appear in the same spot, they only need to be labled x1 through xn. However, they can have a different number of parameters. These can also appear at any given point and must be labled p1 through pn. Parameters and variables can not have the label x0 or p0.
The Matrix has to be in a form, where each column corresponds to a variable. So the i-th column corresponds to the variable xi. Each row is another set of variables to use for an expression. For each expression, every row is used to calculate a result. The Matrix is being read in column-major order. This means that each column corresponds to a set of variables to use for the expressions. Row 1 through row n are then used to retrieve the values for x1 through xn.
Every inner vector of the parameters corresponds to an expression. So the i-th inner vector stores the parameter values for the i-th expression. Parameter pi corresponds to the value stored at index i of the inner vector. Every inner vector of the parameters corresponds to an expression. So the i-th inner vector stores the parameter values for the i-th expression. Parameter pi corresponds to the value stored at index i of the inner vector.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 152 KiB

View File

@ -1,6 +1,6 @@
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0" version="24.7.4"> <mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0" version="24.7.6">
<diagram name="Page-1" id="gpsZjoig8lt5hVv5Hzwz"> <diagram name="Page-1" id="gpsZjoig8lt5hVv5Hzwz">
<mxGraphModel dx="1195" dy="652" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0"> <mxGraphModel dx="989" dy="539" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root> <root>
<mxCell id="0" /> <mxCell id="0" />
<mxCell id="1" parent="0" /> <mxCell id="1" parent="0" />
@ -40,6 +40,24 @@
<mxPoint x="200" as="targetPoint" /> <mxPoint x="200" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-18" value="e1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" vertex="1" parent="9Xn2HrUYLFHSwPnNgvM3-13">
<mxGeometry width="40" height="40" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-19" value="e2" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" vertex="1" parent="9Xn2HrUYLFHSwPnNgvM3-13">
<mxGeometry x="40" width="40" height="40" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-20" value="e3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" vertex="1" parent="9Xn2HrUYLFHSwPnNgvM3-13">
<mxGeometry x="80" width="40" height="40" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-21" value="e4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" vertex="1" parent="9Xn2HrUYLFHSwPnNgvM3-13">
<mxGeometry x="120" width="40" height="40" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-22" value="e5" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" vertex="1" parent="9Xn2HrUYLFHSwPnNgvM3-13">
<mxGeometry x="160" width="40" height="40" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-23" value="e6" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" vertex="1" parent="9Xn2HrUYLFHSwPnNgvM3-13">
<mxGeometry x="200" width="40" height="40" as="geometry" />
</mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-14" value="" style="group" parent="1" vertex="1" connectable="0"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-14" value="" style="group" parent="1" vertex="1" connectable="0">
<mxGeometry x="880" y="360" width="240" height="40" as="geometry" /> <mxGeometry x="880" y="360" width="240" height="40" as="geometry" />
</mxCell> </mxCell>
@ -104,30 +122,30 @@
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-23" value="" style="rounded=0;whiteSpace=wrap;html=1;rotation=90;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-23" value="" style="rounded=0;whiteSpace=wrap;html=1;rotation=90;" parent="1" vertex="1">
<mxGeometry x="820" y="540" width="240" height="40" as="geometry" /> <mxGeometry x="980" y="540" width="240" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-25" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-25" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="920" y="520" as="sourcePoint" /> <mxPoint x="1080" y="520" as="sourcePoint" />
<mxPoint x="960" y="520" as="targetPoint" /> <mxPoint x="1120" y="520" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-26" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-26" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="920" y="560" as="sourcePoint" /> <mxPoint x="1080" y="560" as="sourcePoint" />
<mxPoint x="960" y="560" as="targetPoint" /> <mxPoint x="1120" y="560" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-27" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-27" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="920" y="600" as="sourcePoint" /> <mxPoint x="1080" y="600" as="sourcePoint" />
<mxPoint x="960" y="600" as="targetPoint" /> <mxPoint x="1120" y="600" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-28" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-28" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="920" y="640" as="sourcePoint" /> <mxPoint x="1080" y="640" as="sourcePoint" />
<mxPoint x="960" y="640" as="targetPoint" /> <mxPoint x="1120" y="640" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-16" value="" style="rounded=0;whiteSpace=wrap;html=1;rotation=90;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-16" value="" style="rounded=0;whiteSpace=wrap;html=1;rotation=90;" parent="1" vertex="1">
@ -164,12 +182,12 @@
<mxGeometry x="1040" y="440" width="40" height="40" as="geometry" /> <mxGeometry x="1040" y="440" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-51" value="" style="rounded=0;whiteSpace=wrap;html=1;rotation=90;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-51" value="" style="rounded=0;whiteSpace=wrap;html=1;rotation=90;" parent="1" vertex="1">
<mxGeometry x="1040" y="480" width="120" height="40" as="geometry" /> <mxGeometry x="880" y="480" width="120" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-53" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-53" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="1080" y="520" as="sourcePoint" /> <mxPoint x="920" y="520" as="sourcePoint" />
<mxPoint x="1120" y="520" as="targetPoint" /> <mxPoint x="960" y="520" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-58" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-58" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
@ -180,8 +198,8 @@
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-59" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-59" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="920" y="480" as="sourcePoint" /> <mxPoint x="1080" y="480" as="sourcePoint" />
<mxPoint x="960" y="480" as="targetPoint" /> <mxPoint x="1120" y="480" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-60" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-60" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
@ -198,8 +216,8 @@
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-62" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-62" value="" style="endArrow=none;html=1;rounded=0;exitX=0.167;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.167;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="1080" y="480" as="sourcePoint" /> <mxPoint x="920" y="480" as="sourcePoint" />
<mxPoint x="1120" y="480" as="targetPoint" /> <mxPoint x="960" y="480" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-64" value="" style="endArrow=classic;html=1;rounded=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-64" value="" style="endArrow=classic;html=1;rounded=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" edge="1">
@ -257,22 +275,22 @@
<mxGeometry x="880" y="560" width="40" height="40" as="geometry" /> <mxGeometry x="880" y="560" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-83" value="p1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-83" value="p1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="920" y="440" width="40" height="40" as="geometry" /> <mxGeometry x="1080" y="440" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-84" value="p2" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-84" value="p2" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="920" y="480" width="40" height="40" as="geometry" /> <mxGeometry x="1080" y="480" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-85" value="p3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-85" value="p3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="920" y="520" width="40" height="40" as="geometry" /> <mxGeometry x="1080" y="520" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-86" value="p4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-86" value="p4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="920" y="560" width="40" height="40" as="geometry" /> <mxGeometry x="1080" y="560" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-87" value="&lt;div&gt;p5&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-87" value="&lt;div&gt;p5&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="920" y="600" width="40" height="40" as="geometry" /> <mxGeometry x="1080" y="600" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-88" value="p6" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-88" value="p6" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="920" y="640" width="40" height="40" as="geometry" /> <mxGeometry x="1080" y="640" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-89" value="p1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-89" value="p1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="960" y="440" width="40" height="40" as="geometry" /> <mxGeometry x="960" y="440" width="40" height="40" as="geometry" />
@ -299,13 +317,13 @@
<mxGeometry x="1040" y="440" width="40" height="40" as="geometry" /> <mxGeometry x="1040" y="440" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-97" value="p1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-97" value="p1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="1080" y="440" width="40" height="40" as="geometry" /> <mxGeometry x="920" y="440" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-98" value="p2" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-98" value="p2" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="1080" y="480" width="40" height="40" as="geometry" /> <mxGeometry x="920" y="480" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-99" value="p3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-99" value="p3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="1080" y="520" width="40" height="40" as="geometry" /> <mxGeometry x="920" y="520" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-100" value="" style="endArrow=classic;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-1" edge="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-100" value="" style="endArrow=classic;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
@ -370,25 +388,25 @@
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-107" value="" style="rounded=0;whiteSpace=wrap;html=1;direction=south;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-107" value="" style="rounded=0;whiteSpace=wrap;html=1;direction=south;" parent="1" vertex="1">
<mxGeometry x="560" y="480" width="120" height="160" as="geometry" /> <mxGeometry x="560" y="480" width="120" height="160" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-109" value="" style="endArrow=none;html=1;rounded=0;exitX=0;exitY=0;exitDx=0;exitDy=0;" parent="1" edge="1" source="9Xn2HrUYLFHSwPnNgvM3-117"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-109" value="" style="endArrow=none;html=1;rounded=0;exitX=0;exitY=0;exitDx=0;exitDy=0;" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-117" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="720" y="520" as="sourcePoint" /> <mxPoint x="720" y="520" as="sourcePoint" />
<mxPoint x="560" y="520" as="targetPoint" /> <mxPoint x="560" y="520" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-110" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;" parent="1" edge="1" source="9Xn2HrUYLFHSwPnNgvM3-123"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-110" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-123" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="640" y="599.31" as="sourcePoint" /> <mxPoint x="640" y="599.31" as="sourcePoint" />
<mxPoint x="640" y="480" as="targetPoint" /> <mxPoint x="640" y="480" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-111" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;" parent="1" edge="1" source="9Xn2HrUYLFHSwPnNgvM3-119"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-111" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-119" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="599.52" y="600" as="sourcePoint" /> <mxPoint x="599.52" y="600" as="sourcePoint" />
<mxPoint x="599.52" y="480.69000000000005" as="targetPoint" /> <mxPoint x="599.52" y="480.69000000000005" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-114" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" parent="1" edge="1" source="9Xn2HrUYLFHSwPnNgvM3-117"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-114" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-117" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="720" y="559.76" as="sourcePoint" /> <mxPoint x="720" y="559.76" as="sourcePoint" />
<mxPoint x="560" y="559.76" as="targetPoint" /> <mxPoint x="560" y="559.76" as="targetPoint" />
@ -406,6 +424,14 @@
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-118" value="x3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-118" value="x3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1">
<mxGeometry x="640" y="560" width="40" height="40" as="geometry" /> <mxGeometry x="640" y="560" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-119">
<mxGeometry relative="1" as="geometry">
<mxPoint x="720" y="740" as="targetPoint" />
<Array as="points">
<mxPoint x="620" y="740" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-119" value="x4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-119" value="x4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1">
<mxGeometry x="600" y="600" width="40" height="40" as="geometry" /> <mxGeometry x="600" y="600" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
@ -418,6 +444,14 @@
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-122" value="x3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-122" value="x3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1">
<mxGeometry x="600" y="560" width="40" height="40" as="geometry" /> <mxGeometry x="600" y="560" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-123">
<mxGeometry relative="1" as="geometry">
<mxPoint x="720" y="780" as="targetPoint" />
<Array as="points">
<mxPoint x="660" y="780" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-123" value="x4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-123" value="x4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1">
<mxGeometry x="640" y="600" width="40" height="40" as="geometry" /> <mxGeometry x="640" y="600" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
@ -430,16 +464,24 @@
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-126" value="x3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-126" value="x3" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1">
<mxGeometry x="560" y="560" width="40" height="40" as="geometry" /> <mxGeometry x="560" y="560" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-127">
<mxGeometry relative="1" as="geometry">
<mxPoint x="720" y="700" as="targetPoint" />
<Array as="points">
<mxPoint x="580" y="700" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="9Xn2HrUYLFHSwPnNgvM3-127" value="x4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1"> <mxCell id="9Xn2HrUYLFHSwPnNgvM3-127" value="x4" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;direction=south;" parent="1" vertex="1">
<mxGeometry x="560" y="600" width="40" height="40" as="geometry" /> <mxGeometry x="560" y="600" width="40" height="40" as="geometry" />
</mxCell> </mxCell>
<mxCell id="J6L5rIkjYbQ64Ew3ZQAR-1" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-118"> <mxCell id="J6L5rIkjYbQ64Ew3ZQAR-1" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" parent="1" source="9Xn2HrUYLFHSwPnNgvM3-118" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="720" y="600" as="sourcePoint" /> <mxPoint x="720" y="600" as="sourcePoint" />
<mxPoint x="560" y="600" as="targetPoint" /> <mxPoint x="560" y="600" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="J6L5rIkjYbQ64Ew3ZQAR-2" value="" style="endArrow=classic;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1"> <mxCell id="J6L5rIkjYbQ64Ew3ZQAR-2" value="" style="endArrow=classic;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="540" y="400" as="sourcePoint" /> <mxPoint x="540" y="400" as="sourcePoint" />
<mxPoint x="580" y="480" as="targetPoint" /> <mxPoint x="580" y="480" as="targetPoint" />
@ -449,7 +491,7 @@
</Array> </Array>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="J6L5rIkjYbQ64Ew3ZQAR-3" value="" style="endArrow=classic;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1"> <mxCell id="J6L5rIkjYbQ64Ew3ZQAR-3" value="" style="endArrow=classic;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="580" y="400" as="sourcePoint" /> <mxPoint x="580" y="400" as="sourcePoint" />
<mxPoint x="620" y="480" as="targetPoint" /> <mxPoint x="620" y="480" as="targetPoint" />
@ -459,7 +501,7 @@
</Array> </Array>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="J6L5rIkjYbQ64Ew3ZQAR-4" value="" style="endArrow=classic;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1"> <mxCell id="J6L5rIkjYbQ64Ew3ZQAR-4" value="" style="endArrow=classic;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="620" y="400" as="sourcePoint" /> <mxPoint x="620" y="400" as="sourcePoint" />
<mxPoint x="660" y="480" as="targetPoint" /> <mxPoint x="660" y="480" as="targetPoint" />
@ -469,13 +511,13 @@
</Array> </Array>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="J6L5rIkjYbQ64Ew3ZQAR-5" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1"> <mxCell id="J6L5rIkjYbQ64Ew3ZQAR-5" value="" style="endArrow=none;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="660" y="470" as="sourcePoint" /> <mxPoint x="660" y="470" as="sourcePoint" />
<mxPoint x="660" y="400" as="targetPoint" /> <mxPoint x="660" y="400" as="targetPoint" />
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="J6L5rIkjYbQ64Ew3ZQAR-9" value="" style="endArrow=none;html=1;rounded=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" target="9Xn2HrUYLFHSwPnNgvM3-1"> <mxCell id="J6L5rIkjYbQ64Ew3ZQAR-9" value="" style="endArrow=none;html=1;rounded=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;edgeStyle=orthogonalEdgeStyle;" parent="1" target="9Xn2HrUYLFHSwPnNgvM3-1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="660" y="440" as="sourcePoint" /> <mxPoint x="660" y="440" as="sourcePoint" />
<mxPoint x="710" y="403.5" as="targetPoint" /> <mxPoint x="710" y="403.5" as="targetPoint" />
@ -484,7 +526,7 @@
</Array> </Array>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="J6L5rIkjYbQ64Ew3ZQAR-10" value="" style="endArrow=none;html=1;rounded=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1"> <mxCell id="J6L5rIkjYbQ64Ew3ZQAR-10" value="" style="endArrow=none;html=1;rounded=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;edgeStyle=orthogonalEdgeStyle;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry"> <mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="700" y="440" as="sourcePoint" /> <mxPoint x="700" y="440" as="sourcePoint" />
<mxPoint x="740" y="400" as="targetPoint" /> <mxPoint x="740" y="400" as="targetPoint" />
@ -493,6 +535,63 @@
</Array> </Array>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-9" value="" style="group" vertex="1" connectable="0" parent="1">
<mxGeometry x="721" y="680" width="240" height="120" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-1" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="9og6d5YY-6gPx96OlZrF-9">
<mxGeometry width="240" height="120" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-2" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="9og6d5YY-6gPx96OlZrF-9">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="200" y="120" as="sourcePoint" />
<mxPoint x="200" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-3" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="9og6d5YY-6gPx96OlZrF-9">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint y="40" as="sourcePoint" />
<mxPoint x="240" y="40" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-4" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="9og6d5YY-6gPx96OlZrF-9">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint y="80" as="sourcePoint" />
<mxPoint x="240" y="80" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-5" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="9og6d5YY-6gPx96OlZrF-9">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="40" y="120" as="sourcePoint" />
<mxPoint x="40" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-6" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="9og6d5YY-6gPx96OlZrF-9">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="80" y="120" as="sourcePoint" />
<mxPoint x="80" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-7" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="9og6d5YY-6gPx96OlZrF-9">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="119.65999999999997" y="120" as="sourcePoint" />
<mxPoint x="119.65999999999997" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-8" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="9og6d5YY-6gPx96OlZrF-9">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="160" y="120" as="sourcePoint" />
<mxPoint x="160" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-10" value="&lt;div&gt;Results&lt;/div&gt;&lt;div&gt;Matrix&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="721" y="630" width="70" height="40" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-16" value="" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;labelPosition=left;verticalLabelPosition=middle;align=right;verticalAlign=middle;rotation=-90;" vertex="1" parent="1">
<mxGeometry x="832" y="701" width="20" height="240" as="geometry" />
</mxCell>
<mxCell id="9og6d5YY-6gPx96OlZrF-17" value="Expression 1 through Expression n" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="727" y="832" width="230" height="30" as="geometry" />
</mxCell>
</root> </root>
</mxGraphModel> </mxGraphModel>
</diagram> </diagram>

View File

@ -12,80 +12,94 @@ export interpret
- parameters::Vector{Vector{Float64}} : The parameters to use. Each Vector contains the values for the parameters p1..pn. The number of parameters can be different for every expression - parameters::Vector{Vector{Float64}} : The parameters to use. Each Vector contains the values for the parameters p1..pn. The number of parameters can be different for every expression
" "
function interpret(expressions::Vector{ExpressionProcessing.PostfixType}, variables::Matrix{Float64}, parameters::Vector{Vector{Float64}}) function interpret(expressions::Vector{ExpressionProcessing.PostfixType}, variables::Matrix{Float64}, parameters::Vector{Vector{Float64}})
# TODO: variableCols = size(variables, 2) # number of sets of variables to use for each expression
# create CUDA array for calculation results
variableRows = size(variables, 1)
cudaVars = CuArray(variables) cudaVars = CuArray(variables)
cudaParams = create_cuda_array(parameters, NaN64) # column corresponds to data for one expression cudaParams = create_cuda_array(parameters, NaN64) # column corresponds to data for one expression
cudaExprs = create_cuda_array(expressions, ExpressionElement(EMPTY, 0)) # column corresponds to data for one expression cudaExprs = create_cuda_array(expressions, ExpressionElement(EMPTY, 0)) # column corresponds to data for one expression
cudaStepsize = CuArray([get_max_inner_length(expressions), get_max_inner_length(parameters)]) # put into seperate cuArray, as this is static and would be inefficient to send seperatly to every kernel # put into seperate cuArray, as this is static and would be inefficient to send seperatly to every kernel
cudaStepsize = CuArray([get_max_inner_length(expressions), get_max_inner_length(parameters), size(variables, 1)]) # max num of values per expression; max nam of parameters per expression; number of variables per expression
# each expression has nr. of variable sets (nr. of columns of the variables) results and there are n expressions
cudaResults = CuArray{Float64}(undef, length(expressions), variableCols)
# Start kernel for each expression to ensure that no warp is working on different expressions # Start kernel for each expression to ensure that no warp is working on different expressions
for i in eachindex(expressions) for i in eachindex(expressions)
kernel = @cuda launch=false interpret_expression(cudaExprs, cudaVars, cudaParams, cudaStepsize, i) kernel = @cuda launch=false interpret_expression(cudaExprs, cudaVars, cudaParams, cudaResults, cudaStepsize, i)
config = launch_configuration(kernel.fun) config = launch_configuration(kernel.fun)
threads = min(variableRows, config.threads) threads = min(variableCols, config.threads)
blocks = cld(variableRows, threads) blocks = cld(variableCols, threads)
# TODO: Operation stack should be n-dims. nr. of Rows == length of this expression kernel(cudaExprs, cudaVars, cudaParams, cudaResults, cudaStepsize, i; threads, blocks)
# nr. of columns == nr. of rows in Vars
# This means every run with different variable set has its own stack
# cudaOperationStack = CuArray{Float64}(undef, get_max_inner_length(expressions), length(expressions))
kernel(cudaExprs, cudaVars, cudaParams, cudaStepsize, i; threads, blocks)
end end
end end
const MAX_STACK_SIZE = 25 # The max number of values the expression can have. so Constant values, Variables and parameters const MAX_STACK_SIZE = 25 # The max number of values the expression can have. so Constant values, Variables and parameters
function interpret_expression(expressions::CuDeviceArray{ExpressionElement}, variables::CuDeviceArray{Float64}, parameters::CuDeviceArray{Float64}, stepsize::CuDeviceArray{Int}, exprIndex::Int) function interpret_expression(expressions::CuDeviceArray{ExpressionElement}, variables::CuDeviceArray{Float64}, parameters::CuDeviceArray{Float64}, results::CuDeviceArray{Float64}, stepsize::CuDeviceArray{Int}, exprIndex::Int)
firstExprIndex = ((exprIndex - 1) * stepsize[1]) + 1 # Inclusive firstExprIndex = ((exprIndex - 1) * stepsize[1]) + 1 # Inclusive
lastExprIndex = firstExprIndex + stepsize[1] - 1 # Inclusive lastExprIndex = firstExprIndex + stepsize[1] - 1 # Inclusive
firstParamIndex = ((exprIndex - 1) * stepsize[2]) # Exclusive firstParamIndex = ((exprIndex - 1) * stepsize[2]) # Exclusive
# lastParamIndex = firstParamIndex + stepsize[2] - 1 # Inclusive (probably not needed) # lastParamIndex = firstParamIndex + stepsize[2] - 1 # Inclusive (probably not needed)
operationStack = MVector{MAX_STACK_SIZE, Float64}(undef) # Vector{Float64}(undef, MAX_STACK_SIZE) # Try to get this to function with variable size too
operationStackTop = 1
for i in reverse(firstExprIndex:lastExprIndex) # Calculate real "lastExprIndex" variableCols = length(variables) / stepsize[3]
if expressions[i].Type != EMPTY firstVariableIndex = ((exprIndex - 1) * stepsize[3]) # Exclusive # TODO: This is obviously not right because each expression calculates the cudaResults for each variable set and therefore needs to incorporate the block index + stride. This is only done for testing
lastExprIndex = i firstResultsIndex = ((exprIndex - 1) * variableCols) + 1 # Inclusive # TODO: Same as above. to get the index of the variable set and therefore the index in the results matrix, use the block index and stride
break
end
end
for i in 1:5
@cuprintln(variables[i])
end
operationStack = MVector{MAX_STACK_SIZE, Float64}(undef) # Try to get this to function with variable size too, to allow better memory usage
operationStackTop = 0 # stores index of the last defined/valid value
# TODO: Look into Index and stride for the case that one thread handles multiple "variable sets"
return return
for i in firstExprIndex:lastExprIndex for i in firstExprIndex:lastExprIndex
if expressions[i].Type == EMPTY if expressions[i].Type == EMPTY
break break
elseif expressions[i].Type == INDEX elseif expressions[i].Type == INDEX
# TODO: Load value from variables/parameters matrix and store for calculation
val = expressions[i].Value val = expressions[i].Value
operationStackTop += 1
if val > 0 if val > 0
# TODO: access variables operationStack[operationStackTop] = variables[firstVariableIndex + val]
else else
val = abs(val) val = abs(val)
operationStack[operationStackTop] = parameters[firstParamIndex + val] operationStack[operationStackTop] = parameters[firstParamIndex + val]
end end
operationStackTop += 1
elseif expressions[i].Type == FLOAT64 elseif expressions[i].Type == FLOAT64
operationStack[operationStackTop] = expressions[i].Value
operationStackTop += 1 operationStackTop += 1
operationStack[operationStackTop] = reinterpret(Float64, expressions[i].Value)
elseif expressions[i].Type == OPERATOR elseif expressions[i].Type == OPERATOR
# TODO: Perform calculation of the stored values. Either 1 or 2, depending on the operator # TODO Maybe put this in seperate function
continue type = expressions[i].Type
if type == ADD
operationStackTop -= 1
operationStack[operationStackTop] = operationStack[operationStackTop] + operationStack[operationStackTop + 1]
elseif type == SUBTRACT
operationStackTop -= 1
operationStack[operationStackTop] = operationStack[operationStackTop] - operationStack[operationStackTop + 1]
elseif type == MULTIPLY
operationStackTop -= 1
operationStack[operationStackTop] = operationStack[operationStackTop] * operationStack[operationStackTop + 1]
elseif type == DIVIDE
operationStackTop -= 1
operationStack[operationStackTop] = operationStack[operationStackTop] / operationStack[operationStackTop + 1]
elseif type == POWER
operationStackTop -= 1
operationStack[operationStackTop] = operationStack[operationStackTop] ^ operationStack[operationStackTop + 1]
elseif type == ABS
operationStack[operationStackTop] = abs(operationStack[operationStackTop])
elseif type == LOG
operationStack[operationStackTop] = log(operationStack[operationStackTop])
elseif type == EXP
operationStack[operationStackTop] = exp(operationStack[operationStackTop])
elseif type == SQRT
operationStack[operationStackTop] = sqrt(operationStack[operationStackTop])
end
else else
# TODO: handle this case. Should not happen but in case it does, it needs to do something operationStack[operationStackTop] = NaN
continue break
end end
end end
# TODO: Store computed value in output matrix # results[] = operationStack[operationStackTop]
return return
end end
@ -131,7 +145,6 @@ end
# @deprecate InterpretExplicit!(op::Operator, x, y) interpret_expression(expression, variables, parameters, exprIndex::Int)
# Kernel # Kernel
function InterpretExplicit!(op::Operator, x, y) function InterpretExplicit!(op::Operator, x, y)
index = (blockIdx().x - 1) * blockDim().x + threadIdx().x index = (blockIdx().x - 1) * blockDim().x + threadIdx().x

View File

@ -39,4 +39,8 @@ end
result = Interpreter.convert_to_matrix(parameters, NaN64) result = Interpreter.convert_to_matrix(parameters, NaN64)
@test isequal(result, reference) @test isequal(result, reference)
end end
# TODO: Add several tests fo the mathematical expressions
# One test for each operator. A second test if the operation order matters
# And some more complicated expressions, with some only having variables, some only having parameters and some having both