Every Mica program links a runtime floor, the library beneath the standard library that keeps the heap, the strings, the files and the failure reports. The full floor carries two more parts: the scheduler beneath tasks, generators and streams, and the tensor kernels beneath tensor arithmetic, tracked values and work placed on a GPU. A program that uses neither can stand on the light floor, which leaves both out, at about half the full floor’s archive:

--runtime-profile full     the default: the floor with the scheduler and the tensor kernels
--runtime-profile light    the floor without them
Two floors beneath one standard libraryA program stands on the standard library, and the standard library on a runtime floor, above the C library and Linux. Two floors are drawn side by side. The full floor, which --runtime-profile full selects, carries the heap and strings with files, sockets, pipes and sleep, the scheduler beneath tasks, generators and streams, and the tensor kernels beneath tensor arithmetic, the tape and on gpu. The light floor, which --runtime-profile light selects, carries the first part alone; where the other two stand, it has nothing.your programthe standard librarythe full floor--runtime-profile fullheap and stringsfiles, sockets, pipes, sleepthe schedulertasks, generators, streamsthe tensor kernelstensor arithmetic, tape, on gputhe light floor--runtime-profile lightheap and stringsfiles, sockets, pipes, sleepno schedulerno tensor kernelsthe C library and Linux

Two floors beneath one standard library. Both carry the heap, the strings, the files, the sockets, the pipes and the clock; only the full floor carries the scheduler and the tensor kernels.

The source does not change, and the standard library does not change: the profile selects the floor at the link, as the memory class does.

A program on the light floor

Save this as Ticks.mica:

{
    Ticks - a program the light runtime profile serves: it counts three ticks and sleeps before each.

    The light floor carries no scheduler, so the sleep is a plain blocking call: the program's one thread waits, and
    nothing else is waiting to run.
}
program Ticks;

imp
    WriteLn : std;
    Sleep, Millisecond : time;

const
    { The program counts this many ticks and waits this many milliseconds before each one. }
    TickCount = 3;
    TickPause = 2;

var
    tick : int64;

begin
    for tick := 1 to TickCount do
    begin
        Sleep(TickPause * Millisecond);
        WriteLn("tick %lld", tick);
    end;
end.

Build it on the light floor and run it:

mica --compile --link --runtime-profile light --source Ticks.mica --build build
./build/Ticks
tick 1
tick 2
tick 3

Strings, maps, new and dispose, both memory classes, files, sockets, pipes and sleeping all work on the light floor. A wait is a plain blocking call there: the program has one thread, and it waits. The program’s manifest names the floor it stands on and the optional parts that floor carries, none:

mica --inspect build/Ticks | jq -c '{runtime_profile, floor}'
{"runtime_profile":"light","floor":{"families":[]}}

What the light floor refuses where it is declared

A task, a generator, a stream, a tracked value, a tape window, an on gpu placement and the calls only the scheduler answers, such as Yield, each need a part the light floor leaves out. Before it compiles, the compiler reads which parts the floor it resolved carries, and refuses each of them where it is declared, whether or not the program uses it. Save this as Talkers.mica:

{
    Talkers - a program the light runtime profile refuses: it declares a task.

    A task needs the scheduler, a part of the runtime the light floor leaves out, so the compiler refuses it where it is
    declared, whether or not the program starts it.
}
program Talkers;

imp
    WriteLn : std;

{ A talker runs as a task beside the program body. }
task Talker(lines : int64);
begin
end;

begin
    WriteLn("never built on the light floor");
end.
mica --compile --link --runtime-profile light --source Talkers.mica --build build
analyzer error 5805 [13,6]: 'Talker' is a task, and the runtime floor
'mica-dragon-rt-sites-light-arm64.a' carries no 'tasking' family: build the
program on the full runtime profile, whose floor carries it, or write the work
as a routine

The refusal names the construct, the part of the floor it needs, the floor the build resolved and the way out. The same program builds on the full floor, the default, and the editor shows the same error while you type when the project file states the light profile.

Tensors: storage serves, arithmetic needs the kernels

A tensor is judged by what the program does with it. Holding one, copying it, reading and writing its elements, and adding two fixed vectors need nothing of the floor, so they build and run on the light floor. Save this as Square.mica:

{
    Square - a matrix the light runtime profile serves: the program fills it and reads it element by element.

    Holding a tensor needs nothing of the runtime floor, so the light floor serves the declaration, the stores and the
    reads; only arithmetic that calls the tensor kernels, such as a matrix product, needs the full floor.
}
program Square;

imp
    WriteLn : std;

var
    square : matrix[2, 2] of float64;

begin
    square[0, 0] := 1.0;
    square[0, 1] := 2.0;
    square[1, 0] := 3.0;
    square[1, 1] := 4.0;
    WriteLn("trace %.1lf", square[0, 0] + square[1, 1]);
end.
mica --compile --link --runtime-profile light --source Square.mica --build build
./build/Square
trace 5.0

A matrix product calls the tensor kernels. Put square := square * square; in front of the WriteLn line and build again:

emitter error 22080 [20,22]: this operation needs the runtime floor's tensor
kernels, which the floor 'mica-dragon-rt-sites-light-arm64.a' leaves out: its
code refers to '__mica_tensor_product_f64' of the 'tensor' family; build the
program on the full runtime profile, whose floor carries it, or compute it
element by element

The product is refused at its operator, as the compiler writes its code. The editor writes no code, so it shows nothing here; the build does.

In the project file

A program written for the light floor says so in its project file, in the words of the flag:

{
    "sources": ["Ticks.mica"],
    "version": "1.0.0",
    "runtime-profile": "light"
}

The build, mica --run and the editor all read the entry, and a flag still has the last word: --runtime-profile full on the command line builds that one program on the full floor.

Libraries

A Mica library records the optional parts of the floor its code reaches, and those of every Mica library it imports. A program on the light floor imports a library that reaches neither part, whatever profile the library was built for, and refuses one that reaches either at the import:

analyzer error 5806: the library 'Lone', or a library it imports, reaches the runtime floor's 'tasking' family, and the runtime floor 'mica-dragon-rt-sites-light-arm64.a' carries no 'tasking' family: build the program on the full runtime profile, whose floor carries it, or import a build of the library that does not reach it

A program on the light floor links a Mica library as an archive; a Mica shared object names the shared twin of its floor, which the light floor does not have, so it is refused at the link. A library built on the light profile cannot export a generator template.

What it does not do

A program on the light floor runs on one thread, with no scheduler beneath it, so there are no carriers to pool and no worker processes to count: --tasking multicore and --processes are refused beside the light profile by name, before anything compiles. The light floor has no shared twin and no build under a sanitizer, so a library built on it links as an archive, and --sanitize is refused beside it. The command line lists each refusal in the compiler’s words.

Next

  • Memory classes: the other choice of the floor, the hosted heap or one fixed arena.
  • The program manifest: what a binary states about the floor and the build it was made for.