Skip to content

Commit

Permalink
Do not add Graal at runtime, and instead require including it at buil…
Browse files Browse the repository at this point in the history
…d time

* Remove 'jt install graal', it's nothing more than 'jt build --graal' now.
* Remove the --no-graal option for 'jt benchmark'.
  Whether Graal is included is decided by what is built.
* Update documentation.
  • Loading branch information
eregon committed May 21, 2019
1 parent 7dc9597 commit 14f7836
Show file tree
Hide file tree
Showing 18 changed files with 57 additions and 201 deletions.
4 changes: 2 additions & 2 deletions bench/optcarrot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The code is imported from revision `898783836dfcec04d25a8e7d4b1ce3ce3bbcebdd`.

The emulator can be run with the SDL2 GUI with:
```
$ jt install graal
$ jt build --graal
$ jt ruby --graal bench/optcarrot/bin/optcarrot --sdl2 --audio=none bench/optcarrot/examples/Lan_Master.nes
$ jt ruby bench/optcarrot/bin/optcarrot --sdl2 --audio=none bench/optcarrot/examples/Lan_Master.nes
```
23 changes: 5 additions & 18 deletions ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,9 @@ local part_definitions = {
graal: {
core: {
is_after+:: ["$.use.build"],
setup+: [
["cd", "../graal/compiler"],
["mx", "build"],
["cd", "../../main"],
],
setup+: jt(["build", "--graal"]),

environment+: {
GRAAL_HOME: "../graal/compiler",
HOST_VM: "server",
HOST_VM_CONFIG: "graal-core",
},
Expand All @@ -153,7 +148,6 @@ local part_definitions = {
environment+: {
HOST_VM: "server",
HOST_VM_CONFIG: "default",
MX_NO_GRAAL: "true",
},
},

Expand All @@ -170,14 +164,9 @@ local part_definitions = {
["git", "-C", repo, "checkout", find_commit_importing_truffle],
],

setup+: self.clone + [
["cd", "../graal-enterprise/graal-enterprise"],
["mx", "build"],
["cd", "../../main"],
],
setup+: self.clone + jt(["build", "--dy", "/graal-enterprise"]),

environment+: {
GRAAL_HOME: "$BUILD_DIR/graal-enterprise/graal-enterprise",
HOST_VM: "server",
HOST_VM_CONFIG: "graal-enterprise",
},
Expand All @@ -201,7 +190,6 @@ local part_definitions = {

environment+: {
HOST_VM_CONFIG: "graal-core",
GRAAL_HOME: "$BUILD_DIR/graal/compiler",
VM_SUITE_HOME: "$BUILD_DIR/graal/vm",
},
},
Expand All @@ -215,7 +203,6 @@ local part_definitions = {

environment+: {
HOST_VM_CONFIG: "graal-enterprise",
GRAAL_HOME: "$BUILD_DIR/graal-enterprise/graal-enterprise",
VM_SUITE_HOME: "$BUILD_DIR/graal-enterprise/vm-enterprise",
},
},
Expand Down Expand Up @@ -441,9 +428,9 @@ local part_definitions = {
compiler_metrics: {
# Run all metrics benchmarks: hello and compile-mandelbrot
benchmarks+:: [
["allocation", "--", "--graal"],
["minheap", "--", "--graal"],
["time", "--", "--graal"],
"allocation",
"minheap",
"time",
]
},

Expand Down
18 changes: 16 additions & 2 deletions doc/contributor/benchmarking.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Benchmarking with the GraalVM Compiler

First build TruffleRuby and include the GraalVM Compiler:

```bash
$ jt build --graal
```

Then run the benchmark, for instance:

```bash
$ jt benchmark bench/classic/mandelbrot.rb --simple
```
Expand All @@ -11,10 +19,16 @@ for the first few iterations).

# Benchmarking without the GraalVM Compiler

You can turn off the GraalVM Compiler if you want using `--no-graal`.
You can turn off the GraalVM Compiler if you want, by not including it in the GraalVM build:

```bash
$ jt benchmark --no-graal bench/classic/mandelbrot.rb --simple
$ jt build
```

It's the same command to run the benchmark, for instance:

```bash
$ jt benchmark bench/classic/mandelbrot.rb --simple
```

You can benchmark an entirely different implementation using the
Expand Down
26 changes: 5 additions & 21 deletions doc/contributor/building-graal.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,16 @@ when developing TruffleRuby, or possibly to modify them, or to use developer
tools that come with Graal such as the Ideal Graph Visualizer, then you should
install Graal locally.

## Installing Graal with jt
## Building Graal with jt

Our workflow tool can install Graal automatically under the directory
`../graal/compiler` with:
Our workflow tool can build Graal automatically with:

```bash
$ jt install graal
$ jt build --graal
```

You can then use `jt` to run TruffleRuby with Graal.
You can then use `jt` as normal to run TruffleRuby with Graal.

```bash
$ jt ruby --graal ...
```

## Building Graal manually

If you want to build the GraalVM Compiler by yourself, follow the instructions
in the Graal repository.

https://github.com/oracle/graal

You can then set the `GRAAL_HOME` environment variable to the location of the
`compiler` directory inside the `graal` repository and use `jt` to run
TruffleRuby.

```bash
$ GRAAL_HOME=.../graal/compiler jt ruby --graal ...
$ jt ruby ...
```
4 changes: 2 additions & 2 deletions doc/contributor/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ Ruby command line options and arguments can also be set in `RUBYOPT`.

## Running with Graal

See the document on [build graal](building-graal.md), and then run `jt ruby`
with the `--graal` option.
See the document on [building graal](building-graal.md), and then run `jt ruby`
as normal.

We have flags in `jt` to set some options, such as `--trace` for
`--vm.Dgraal.TraceTruffleCompilation=true` and `--igv` for
Expand Down
5 changes: 1 addition & 4 deletions doc/samples/can-we-fold-yet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

require 'readline'

unless TruffleRuby.jit?
puts 'You need the GraalVM Compiler to run this'
exit
end
abort 'You need the GraalVM Compiler to run this' unless TruffleRuby.jit?

puts 'Can Truffle constant fold yet?'

Expand Down
6 changes: 2 additions & 4 deletions mx.truffleruby/mx_truffleruby_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ def filterLines(self, lines):

def runBenchmark(self, benchmark, bmSuiteArgs):
arguments = ['benchmark']
if 'MX_NO_GRAAL' in os.environ:
arguments.extend(['--no-graal'])
arguments.extend(['--simple', '--elapsed', '--iterations'])
arguments.extend(['--time', str(self.time())])
if ':' in benchmark:
Expand Down Expand Up @@ -586,8 +584,8 @@ def name(self):

def runBenchmark(self, benchmark, bmSuiteArgs):
arguments = ['ruby']
if 'MX_NO_GRAAL' not in os.environ and not bmSuiteArgs:
arguments.extend(['--graal', '--vm.Dgraal.TruffleCompilationExceptionsAreFatal=true'])
if not bmSuiteArgs:
arguments.extend(['--vm.Dgraal.TruffleCompilationExceptionsAreFatal=true'])
arguments.extend(['bench/servers/' + benchmark + '.rb'])

server = BackgroundJT(arguments + bmSuiteArgs)
Expand Down
2 changes: 1 addition & 1 deletion test/truffle/compiler/can-we-fold-yet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source test/truffle/common.sh.inc

jt ruby --graal --vm.Dgraal.TruffleIterativePartialEscape=true doc/samples/can-we-fold-yet.rb < test/truffle/compiler/can-we-fold-yet/input.txt > actual.txt
jt ruby --vm.Dgraal.TruffleIterativePartialEscape=true doc/samples/can-we-fold-yet.rb < test/truffle/compiler/can-we-fold-yet/input.txt > actual.txt

if ! cmp test/truffle/compiler/can-we-fold-yet/expected.txt actual.txt
then
Expand Down
2 changes: 1 addition & 1 deletion test/truffle/compiler/compile-immediately.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

source test/truffle/common.sh.inc

jt ruby --graal --stress --trace -e "puts 'hello'"
jt ruby --stress --trace -e "abort 'not running the GraalVM Compiler' unless TruffleRuby.jit?; puts 'hello'"
2 changes: 1 addition & 1 deletion test/truffle/compiler/osr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

source test/truffle/common.sh.inc

jt ruby --graal --vm.Dgraal.TruffleCompilationExceptionsAreFatal=true test/truffle/compiler/osr/osr.rb
jt ruby --vm.Dgraal.TruffleCompilationExceptionsAreFatal=true test/truffle/compiler/osr/osr.rb
2 changes: 2 additions & 0 deletions test/truffle/compiler/osr/osr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# GNU General Public License version 2, or
# GNU Lesser General Public License version 2.1.

abort 'not running the GraalVM Compiler' unless TruffleRuby.jit?

timeout = Time.now + 30

begin
Expand Down
2 changes: 1 addition & 1 deletion test/truffle/compiler/pe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

source test/truffle/common.sh.inc

jt ruby --graal --vm.Dgraal.TruffleCompilationExceptionsAreThrown=true --vm.Dgraal.TruffleIterativePartialEscape=true --experimental-options --basic-ops-inline=false test/truffle/compiler/pe/pe.rb "$@"
jt ruby --vm.Dgraal.TruffleCompilationExceptionsAreThrown=true --vm.Dgraal.TruffleIterativePartialEscape=true --experimental-options --basic-ops-inline=false test/truffle/compiler/pe/pe.rb "$@"
5 changes: 1 addition & 4 deletions test/truffle/compiler/pe/pe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
#
# jt ruby --graal --vm.Dgraal.TraceTruffleCompilation=true --vm.Dgraal.TruffleCompilationExceptionsAreFatal=true --vm.Dgraal.TruffleIterativePartialEscape=true test.rb

unless TruffleRuby.jit?
puts 'not running the GraalVM Compiler'
exit 1
end
abort 'not running the GraalVM Compiler' unless TruffleRuby.jit?

TIMEOUT = 10

Expand Down
2 changes: 1 addition & 1 deletion test/truffle/compiler/stf-optimises.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

source test/truffle/common.sh.inc

jt ruby --graal --vm.Dgraal.TruffleCompilationExceptionsAreFatal=true test/truffle/compiler/stf-optimises/stf-optimises.rb
jt ruby --vm.Dgraal.TruffleCompilationExceptionsAreFatal=true test/truffle/compiler/stf-optimises/stf-optimises.rb
4 changes: 3 additions & 1 deletion test/truffle/compiler/stf-optimises/stf-optimises.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
# GNU General Public License version 2, or
# GNU Lesser General Public License version 2.1.

abort 'not running the GraalVM Compiler' unless TruffleRuby.jit?

def foo
var = 14
var * 2
end

set_trace_func proc { |event, file, line, id, binding, classname|
if event == 'line' && file == __FILE__ && line == 11
if event == 'line' && file == __FILE__ && line == 13
binding.local_variable_set(:var, 100)
end
}
Expand Down
2 changes: 1 addition & 1 deletion test/truffle/compiler/tp-optimises.sh_excluded
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

source test/truffle/common.sh.inc

jt ruby --graal --vm.Dgraal.TruffleCompilationExceptionsAreFatal=true test/truffle/compiler/tp-optimises/tp-optimises.rb
jt ruby --vm.Dgraal.TruffleCompilationExceptionsAreFatal=true test/truffle/compiler/tp-optimises/tp-optimises.rb
4 changes: 3 additions & 1 deletion test/truffle/compiler/tp-optimises/tp-optimises.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
# GNU General Public License version 2, or
# GNU Lesser General Public License version 2.1.

abort 'not running the GraalVM Compiler' unless TruffleRuby.jit?

def foo
var = 14
var * 2
end

tp = TracePoint.new(:line) do |tp|
if tp.path == __FILE__ && tp.lineno == 11
if tp.path == __FILE__ && tp.lineno == 13
tp.binding.local_variable_set(:var, 100)
end
end
Expand Down
Loading

0 comments on commit 14f7836

Please sign in to comment.