The following code shows a first example of the BondMachine. It is a trival example yet it shows the basic capabilities of the BondMachine architecture and ecosytem. Two Goroutines send an uint8 data value back and forth through IO registers (those created with bondgo.Make), the pong goroutine also increases the value by one before sending it back.
Compiling the code with the bondgo compiler:
The toolchain perform the following steps:
- Map the two goroutines to two hardware cores.
- Creates two types of core, each one optimized to execute the assigned goroutine.
- Creates the two binaries.
- Connected the two core as inferred from the source code, using special IO registers.
The result is a multicore BondMachine:
Changing the device_0 label with device_1 the compiler is instructed to put the two goroutines on different BondMachines. Compiling activating the etherbond protocol
The result will be the same as before (in term of behaviour) but using a cluster of two BondMachines connected via the etherbond protocol, each running only one goroutine.
The Multicore became a distributed system:
The following code shows a similar behaviour but using channels.