Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
# 'Hello, world!' in Chapel

[Chapel](https://github.com/chapel-lang/chapel/) is a programming language for productive parallel computing. This repository contains starter code for a Chapel project. Please see the [Learning Chapel](https://chapel-lang.org/learning.html) page to learn more of the language's features.
[Chapel](https://github.com/chapel-lang/chapel/) is a programming language for productive parallel computing. This repository is a simple starting point for Chapel in GitHub Codespaces, with runnable examples in [examples/](examples).

To get started with this template, you can either use [GitHub Codespaces](#using-a-codespace) or [your own machine](#using-your-machine).
> ⚠️ **Warning:** Codespaces runs in a virtualized environment with shared hardware and a modest core count. Performance and available parallelism in Codespaces are not representative of what you should expect on a native Chapel installation.

For more code samples, consider trying out the [Primers](https://chapel-lang.org/docs/primers/),
or the [many programs from a past Chapel tutorial](https://github.com/chapel-lang/chapel/tree/main/test/exercises/Oct2023tutorial).
## Compile And Run In The Terminal
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Compile And Run In The Terminal
## Compile And Run With The Run Button In Codespaces VS Code
1. Open [hello.chpl](hello.chpl).
2. Wait for the Chapel extension and language tools to finish loading in Codespaces.
3. Click the Run button in the editor (top-right) to first compile and again run the current file.
If the Run button does not appear right away, wait a bit longer and reopen the `.chpl` file.
## Compile And Run In The Terminal

@bradcray suggested we put instructions for using the play button in the VSCode editor. This is an example of how we'd do that if we wanted to.


## Using a Codespace

> :warning: Because Codespaces are a virtualized environment running on shared hardware with a modest core count, don't expect parallelism or performance observed here to be reflective of what a native installation of Chapel can achieve.

The `chapel-hello-world` repo includes a `devcontainer.json` file, making it usable from GitHub Codespaces. When viewing this repository from GitHub's UI, click __Use this template > Open in a codespace__ to get started. The codespace includes the Visual Studio Code extension for Chapel, and tools such as [`chpl-language-server`](https://chapel-lang.org/docs/main/tools/chpl-language-server/chpl-language-server.html) and [`chplcheck`](https://chapel-lang.org/docs/main/tools/chplcheck/chplcheck.html).

In the Codespace, compile Chapel programs using the __Terminal__ tab by using the `chpl` compiler:
Compile and run the main hello-world program:

```bash
chpl hello.chpl
./hello
```

Although the Codespace is set to a single-locale (single-node) mode by default, you can simulate multiple nodes by setting the `CHPL_COMM` environment variable to `gasnet` when compiling.
Compile and run one of the included examples:

```bash
# Compile a program that distributes computation to multiple nodes
CHPL_COMM=gasnet chpl examples/hello4-datapar-dist.chpl
chpl examples/hello3-datapar.chpl
./hello3-datapar
```

## Simulated Distributed (Multi-Locale) Runs

The Codespace defaults to single-locale mode (`CHPL_COMM=none`).

To simulate multi-locale execution, compile with `CHPL_COMM=gasnet`:

# Run hello using two simulated nodes
./hello4-datapar-dist -nl 2
```bash
CHPL_COMM=gasnet chpl examples/hello4-datapar-dist.chpl
./hello4-datapar-dist -nl 2
```

To avoid having to include `CHPL_COMM` in each compilation command, you can
`export` it:
Or export once per shell and compile as usual:

```bash
export CHPL_COMM=gasnet
chpl examples/hello4-datapar-dist.chpl
./hello4-datapar-dist -nl 2
./hello4-datapar-dist -nl 2
```

## Using Your Machine
## Learn More And Try More Programs

Please follow the instructions on the [Download Chapel](https://chapel-lang.org/download.html) page to get set up with the Chapel compiler `chpl`. From there, you can compile and run the `hello.chpl` file in this repository as follows:

```bash
chpl hello.chpl
./hello
```
You can copy in additional examples from Chapel Primers or Chapel tutorial/example programs to explore more language features.

To make use of multiple nodes (or to simulate multi-node execution), please
refer to [Multilocale Chapel Execution](https://chapel-lang.org/docs/usingchapel/multilocale.html).
- [Learning Chapel](https://chapel-lang.org/learning.html)
- [Chapel Primers](https://chapel-lang.org/docs/primers/)
- [Chapel tutorial examples](https://github.com/chapel-lang/chapel/tree/main/test/exercises/Oct2023tutorial)
- [Multilocale Chapel Execution](https://chapel-lang.org/docs/usingchapel/multilocale.html)
- [Download Chapel](https://chapel-lang.org/download.html)