SC26
Audience instructions for the OpenCode exercises in SC26 Tutorial Section 6
SC26 Tutorial · Section 6
OpenCode hands-on instructions
Set up OpenCode once, then run two end-to-end exercises: progressive 2-D Fortran-to-C++ translation with Beyond Code Pairs, and correctness-gated OpenMP parallelization with ParaCodex.
- Step 1Install OpenCode and select a model
- Step 2Clone both exercise repositories
- Step 3Run each command in OpenCode
- Step 4Read code, tests, and transcripts
Install OpenCode and select a model
Install the OpenCode CLI using the official installer, then confirm that the command is available:
curl -fsSL https://opencode.ai/v2/install | bash
opencode --version Homebrew, npm, desktop, and standalone installers are also listed in the official installation guide.
Start OpenCode in a terminal. If a provider or sign-in is required, connect it first. Then open the model selector:
/connect
/models Choose an available model marked Free, or another model supplied by your provider. Free-model availability can change, so select from the live list instead of using a model name from this page. The selection applies to the current session, and both exercises inherit it.
Local prerequisites
Beyond Code Pairs requires Python 3.9+, gfortran, and g++. ParaCodex requires Python 3 and a C++17 compiler with OpenMP support. On macOS, use Homebrew GCC for real OpenMP rather than Apple Clang.
Clone both repositories
Use a new working directory so the exercises stay separate from your own projects:
mkdir sc26-hands-on
cd sc26-hands-on
git clone https://github.com/thelechen/beyond-code-pairs-translation.git
git clone https://github.com/thelechen/ParaCodex.git Each repository contains a self-contained SC26 directory. Start OpenCode from that directory so it can discover the project commands under .opencode/commands/.
Run the exercises in OpenCode
Run one exercise at a time. Beyond Code Pairs always completes three progressively harder reasoning rounds, even when every submitted candidate is correct. Optional repair commands provide clearly labelled, instructor-injected failures.
Beyond Code Pairs
A Questioner and Solver translate a 2-D heat-diffusion routine through three required gates: one stencil step, multi-step double buffering, and model-generated adversarial regression. An independent harness checks every gate.
cd sc26-hands-on/beyond-code-pairs-translation/SC26
make clean
opencode At the OpenCode prompt, enter:
/bcp-demoWatch Gate 1 test 2-D layout and boundaries; Gate 2 add zero/multiple steps, odd/even buffer parity, and final-step change; and Gate 3 add new rectangular/asymmetric tests. After Gate 3 passes, optionally enter /bcp-repair to diagnose a labelled stale-buffer fixture.
ParaCodex
An Analyzer plans the parallelization, a Solver writes OpenMP code, and an independent gate checks compilation, numerical equivalence, and active OpenMP.
cd sc26-hands-on/ParaCodex/SC26
make clean
opencode At the OpenCode prompt, enter:
/paracodex-demoOptionally enter /paracodex-repair to observe the seeded numerical failure, reviewer feedback, and repair.
Starting over
Exit OpenCode, run make clean from the relevant SC26 directory, and reopen opencode. Copy the run directory elsewhere first if you want to keep an earlier result.
Read the results
Do not judge success from the final code alone. Read the generated plan, exact candidate, independent test report, and repair history together.
Beyond Code Pairs results
tutorial_demo/opencode_e2e/runs/opencode_latest/
-
questioner_stage_01.mdthroughquestioner_stage_03.md: the three progressively harder requests -
candidate_gate_XX_attempt_YY.cpp: exact C++ submitted at each gate and attempt -
gate_XX_attempt_YY.json: compiler and case-by-case numerical evidence -
questioner_cases.json: Gate 3's two model-generated adversarial grids -
questioner_feedback_gate_XX_attempt_YY.md: targeted feedback after a real failure -
transcript.mdandevents.jsonl: readable and structured run histories
Success: the latest report for each of Gates 1, 2, and 3 contains "overall_pass": true.
ParaCodex results
tutorial_demo/paracodex_opencode/
-
work/analysis.mdandwork/data_plan.md: dependency and data-movement reasoning -
work/candidate.cpp: current generated OpenMP implementation -
runs/latest/attempt_XX.json: compilation, numerical checks, and OpenMP status -
runs/latest/candidate_attempt_XX.cpp: exact source tested at each gate -
runs/latest/performance.jsonandtranscript.md: timing evidence and run recap
Success: look for PASS_NUMERICS and OPENMP_ACTIVE. NOT_PROVEN_PARALLEL means the compiler fell back to serial execution or no active OpenMP loop was established.