Skip to content

Commit

Permalink
Support latest version of Pharo and reenable CI (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr authored Feb 4, 2024
2 parents 329686c + 6a82a41 commit 3c16f8a
Show file tree
Hide file tree
Showing 21 changed files with 334 additions and 279 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ jobs:
- { name: Crystal, id: crystal, folder: Crystal }
- { name: JavaScript, id: js, folder: JavaScript }
- { name: SOMns, id: somns, folder: SOMns }

#- { name: Pharo, id: pharo, folder: Smalltalk }

- { name: Pharo, id: pharo, folder: Smalltalk }
- { name: Squeak, id: squeak, folder: Smalltalk }
- { name: Ruby, id: ruby, folder: Ruby }
- { name: Lua, id: lua, folder: Lua }
Expand All @@ -39,7 +37,7 @@ jobs:
run: |
git clone --depth 1 https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
~/.asdf/bin/asdf plugin add awfy https://github.com/smarr/asdf-awfy.git
if: matrix.id == 'squeak'
if: matrix.id == 'squeak' || matrix.id == 'pharo'

- name: Install Crystal
if: matrix.id == 'crystal'
Expand All @@ -52,9 +50,11 @@ jobs:
- name: Install Pharo
if: matrix.id == 'pharo'
uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-image: Pharo64-stable
run: |
~/.asdf/bin/asdf install awfy pharo-120
cp ~/.asdf/installs/awfy/pharo-120/Pharo*.sources benchmarks/Smalltalk/
cp ~/.asdf/installs/awfy/pharo-120/Pharo*.image benchmarks/Smalltalk/Pharo.image
cp ~/.asdf/installs/awfy/pharo-120/Pharo*.changes benchmarks/Smalltalk/Pharo.changes
- name: Install Squeak
if: matrix.id == 'squeak'
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/Smalltalk/CD/CD.som
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ CD = Benchmark (
benchmark: numAircrafts = (
| numFrames simulator detector actualCollisions |
numFrames := 200.

simulator := Simulator new: numAircrafts.
detector := CollisionDetector new.

actualCollisions := 0.

0 to: numFrames - 1 do: [:i |
| time collisions |
time := i / 10.0.
collisions := detector handleNewFrame: (simulator simulate: time).
actualCollisions := actualCollisions + collisions size ].

^ actualCollisions
)

innerBenchmarkLoop: innerIterations = (
^ self verify: (self benchmark: innerIterations) resultFor: innerIterations
)

verify: actualCollisions resultFor: numAircrafts = (
numAircrafts = 1000 ifTrue: [ ^ actualCollisions = 14484 ].
numAircrafts = 500 ifTrue: [ ^ actualCollisions = 14484 ].
Expand All @@ -58,14 +58,14 @@ CD = Benchmark (
numAircrafts = 100 ifTrue: [ ^ actualCollisions = 4305 ].
numAircrafts = 10 ifTrue: [ ^ actualCollisions = 390 ].
numAircrafts = 2 ifTrue: [ ^ actualCollisions = 42 ].

ScriptConsole println: ('No verification result for ', numAircrafts asString, ' found.').
ScriptConsole println: ('Result is: ', actualCollisions asString).
^ false
)

----

new = (
Constants initialize.
^ super new
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/Smalltalk/DeltaBlue/BinaryConstraint.som
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ BinaryConstraint = AbstractConstraint (
variables.

Instance variables:
v1, v2 possible output variables <Variable>
v1, v2 possible output variables <DBVariable>
direction one of:
#forward (v2 is output)
#backward ( v1 is output)
nil (not satisfied)"
| v1 v2 direction |

"initialize-release"

initializeVar: variable1 var: variable2 strength: strengthSymbol addTo: planner = (
Expand Down Expand Up @@ -89,7 +89,7 @@ BinaryConstraint = AbstractConstraint (
ifTrue: [ aBlock value: v1 ]
ifFalse: [ aBlock value: v2 ].
)

inputsHasOne: aBlock = (
^ direction = #forward
ifTrue: [ aBlock value: v1 ]
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/Smalltalk/DeltaBlue/EditConstraint.som
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ http://web.archive.org/web/20050825101121/http://www.sunlabs.com/people/mario/ja
EditConstraint = UnaryConstraint (
"I am a unary input constraint used to mark a variable that the client
wishes to change."

"queries"
isInput = (
"I indicate that a variable is to be changed by imperative code."
Expand All @@ -19,15 +19,15 @@ EditConstraint = UnaryConstraint (
execute = (
"Edit constraints do nothing."
)

----

"instance creation"

var: aVariable strength: strengthSymbol addTo: planner = (
var: aDBVariable strength: strengthSymbol addTo: planner = (
"Install an edit constraint with the given strength on the given
variable."

^ self new initializeVar: aVariable strength: strengthSymbol addTo: planner
^ self new initializeVar: aDBVariable strength: strengthSymbol addTo: planner
)
)
24 changes: 12 additions & 12 deletions benchmarks/Smalltalk/DeltaBlue/Planner.som
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ Planner = (
^ true
)

changeVar: aVariable newValue: newValue = (
changeVar: aDBVariable newValue: newValue = (
| editConstraint plan |
editConstraint := EditConstraint var: aVariable strength: Strength SymPreferred addTo: self.
editConstraint := EditConstraint var: aDBVariable strength: Strength SymPreferred addTo: self.
plan := self extractPlanFromConstraints: (Vector with: editConstraint).
10 timesRepeat: [
aVariable value: newValue.
aDBVariable value: newValue.
plan execute ].
editConstraint destroyConstraint: self.
)
Expand Down Expand Up @@ -189,7 +189,7 @@ Planner = (

| unsatisfied todo v |
unsatisfied := Vector new.

out determinedBy: nil.
out walkStrength: Strength absoluteWeakest.
out stay: true.
Expand All @@ -205,9 +205,9 @@ Planner = (
unsatisfied sort: [:c1 :c2 | c1 strength stronger: c2 strength].
^ unsatisfied
)

----

"instance creation"
new = (
^ super new initialize
Expand All @@ -217,11 +217,11 @@ Planner = (
chainTest: n = (
"Do chain-of-equality-constraints performance tests."
| vars editConstraint plan planner |

planner := Planner new.
vars := Array new: n+1.
1 to: n+1 do: [:i |
vars at: i put: Variable new ].
vars at: i put: DBVariable new ].

"thread a chain of equality constraints through the variables"
1 to: n do: [ :i |
Expand Down Expand Up @@ -249,12 +249,12 @@ Planner = (
| scale offset src dst planner dests |
planner := Planner new.
dests := Vector new.
scale := Variable value: 10.
offset := Variable value: 1000.
scale := DBVariable value: 10.
offset := DBVariable value: 1000.

1 to: n do: [ :i |
src := Variable value: i.
dst := Variable value: i.
src := DBVariable value: i.
dst := DBVariable value: i.
dests append: dst.
StayConstraint var: src strength: Strength SymDefault addTo: planner.
ScaleConstraint var: src var: scale var: offset var: dst strength: Strength SymRequired addTo: planner
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/Smalltalk/DeltaBlue/ScaleConstraint.som
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ ScaleConstraint = BinaryConstraint (
this relationship but the scale factor and offset are considered read-only.

Instance variables:
scale scale factor input variable <Variable>
offset offset input variable <Variable>"
scale scale factor input variable <DBVariable>
offset offset input variable <DBVariable>"
| scale offset |

"initialize-release"
initializeSrc: srcVar scale: scaleVar offset: offsetVar dst: dstVar strength: strengthSymbol addTo: planner = (
"Initialize myself with the given variables and strength."
Expand Down Expand Up @@ -77,7 +77,7 @@ ScaleConstraint = BinaryConstraint (
out stay: (in stay and: [scale stay and: [offset stay]]).
out stay ifTrue: [self execute]. "stay optimization"
)

----

"instance creation"
Expand All @@ -87,4 +87,4 @@ ScaleConstraint = BinaryConstraint (
variables."
^ self new initializeSrc: src scale: scale offset: offset dst: dst strength: strengthSymbol addTo: planner
)
)
)
6 changes: 3 additions & 3 deletions benchmarks/Smalltalk/DeltaBlue/StayConstraint.som
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ StayConstraint = UnaryConstraint (
execute = (
"Stay constraints do nothing."
)

----

"instance creation"
var: aVariable strength: strengthSymbol addTo: planner = (
var: aDBVariable strength: strengthSymbol addTo: planner = (
"Install a stay constraint with the given strength on the given variable."

^ self new initializeVar: aVariable strength: strengthSymbol addTo: planner
^ self new initializeVar: aDBVariable strength: strengthSymbol addTo: planner
)
)
10 changes: 5 additions & 5 deletions benchmarks/Smalltalk/DeltaBlue/UnaryConstraint.som
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ UnaryConstraint = AbstractConstraint (
variable.

Instance variables:
output possible output variable <Variable>
output possible output variable <DBVariable>
satisfied true if I am currently satisfied <Boolean>"
| output satisfied |

"initialize-release"

initializeVar: aVariable strength: strengthSymbol addTo: planner = (
initializeVar: aDBVariable strength: strengthSymbol addTo: planner = (
"Initialize myself with the given variable and strength."
super initialize: strengthSymbol.
output := aVariable.
output := aDBVariable.
satisfied := false.
self addConstraint: planner.
)
Expand Down Expand Up @@ -62,7 +62,7 @@ UnaryConstraint = AbstractConstraint (
inputsDo: aBlock = (
"I have no input variables."
)

inputsHasOne: aBlock = (
^ false
)
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/Smalltalk/DeltaBlue/Variable.som
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ License details:

http://web.archive.org/web/20050825101121/http://www.sunlabs.com/people/mario/java_benchmarking/index.html
"
Variable = (
DBVariable = (
"I represent a constrained variable. In addition to my value, I maintain the
structure of the constraint graph, the current dataflow graph, and various
parameters of interest to the DeltaBlue incremental constraint solver.
Expand All @@ -19,7 +19,7 @@ Variable = (
stay true if I am a planning-time constant <Boolean>
mark used by the planner to mark constraints <Number>"
| value constraints determinedBy walkStrength stay mark |

"initialize-release"

initialize = (
Expand Down Expand Up @@ -101,7 +101,7 @@ Variable = (
"Set my walkabout strength in the current dataflow."
walkStrength := aStrength.
)

----

"instance creation"
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/Smalltalk/Harness.som
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"
Harness = (

processArguments: args= (
| run |
"First argument is the Harness"
Expand All @@ -33,21 +33,21 @@ Harness = (
] ].
^ run
)

run: args = (
| run |
args size < 2 ifTrue: [
self printUsage.
Smalltalk exit: 1
].

run := self processArguments: args.

run runBenchmark.
run printTotal.
Smalltalk exit: 0
)

printUsage = (
ScriptConsole println: './som -cp Smalltalk Benchmarks/Harness.som [benchmark] [num-iterations [inner-iter]]'.
ScriptConsole println: ''.
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/Smalltalk/Havlak/Havlak.som
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ limitations under the License.

Havlak = Benchmark (
innerBenchmarkLoop: innerIterations = (
^ self verifyResult:
^ self verifyResult:
(LoopTesterApp new main: innerIterations loop: 50 p: 10 p: 10 p: 5)
iterations: innerIterations
)

verifyResult: result iterations: innerIterations = (
innerIterations = 15000 ifTrue: [ ^ (result at: 1) = 46602 and: [(result at: 2) = 5213] ].
innerIterations = 1500 ifTrue: [ ^ (result at: 1) = 6102 and: [(result at: 2) = 5213] ].
innerIterations = 150 ifTrue: [ ^ (result at: 1) = 2052 and: [(result at: 2) = 5213] ].
innerIterations = 15 ifTrue: [ ^ (result at: 1) = 1647 and: [(result at: 2) = 5213] ].
innerIterations = 1 ifTrue: [ ^ (result at: 1) = 1605 and: [(result at: 2) = 5213] ].

ScriptConsole println: ('No verification result for', innerIterations asString, ' found').
ScriptConsole println: ('Result is ', (result at: 1) asString, ', ', (result at: 2) asString).
^ false
Expand Down
Loading

0 comments on commit 3c16f8a

Please sign in to comment.