Psi Lambda LLC ψ(λκ) Kappa Library User Guide

Errors and Testing

Kappa supplies various mechanisms for performance tracking, error exception handling, and tracing to make it easier to localize errors or perform testing.

Print

The Kappa Process Print statement may be used to display Value objects and to track progress of Kappa Process execution.

Timers

The statement:

!Timer -> <timer_name>;

will, the first time it is given, create a timer. The subsequent times it it is given, it will output to standard error the elapsed time since the timer was last invoked:

Processing time: 42.984 (ms)

The times may include scheduling delays, system overhead and delays, etc.

Context memory usage

The statement:
!Context -> <context_name>;
will, if if is subsequently repeated in the same Kappa Process, report to standard error the device memory usage:
Device: Starting Free Memory: 514719744
Ending: Free Memory: 514719744
Difference Memory: 0
Total: 536674304
Used: 146748
When the “!Context” statement with the same context name is given (repeated), it is given a “final” dependency status. This means that it is deferred for execution until all other dependencies on that named context have finished.

ExceptionHandler

The developer may instantiate a sub-class of the kappa::ExceptionHandler class and use the kappa::Process.SetExceptionHandler method to register to receive exception notifications from the Kappa Process.

SetQueueResults and GetResult

The developer may call the kappa::Process.SetQueueResults method to have kappa::Process start recording command status results to a queue and may call the kappa::Process:GetResult method to retrieve these command status results from a queue.

KAPPA_TRACE

Setting the KAPPA_TRACE operating system environment variable will have the Kappa Process report command statuses as they occur. These statuses report information similar to:

Preparing: !C/Kernel -> CheckGold@(A,B,C,#HA,#WA,#WB,#HC,#WC) [= A B C, = #HA #WA #WB #HC #WC];

Queueing: !C/Kernel -> CheckGold@(A,B,C,#HA,#WA,#WB,#HC,#WC) [= A B C, = #HA #WA #WB #HC #WC];

Finished kappa::command::C::kernel /kappa/context/main/context/CheckGold@(A,B,C,#HA,#WA,#WB,#HC,#WC) [= A B C, = #HA #WA #WB #HC #WC] 113808

Preparing: !Free -> A;

Queueing: !Free -> A;

Canceled kappa::command::VariableDone /kappa/context/main/context/A 113808

Please note that it is fine for commands to respond with a CANCELED instead of FINISHED status. Most commands that finalize (free) resources should respond with a CANCELED status so that further processing with those resources does not occur.

Please also note that full, internal, namespace name is usually what is reported in this trace. For example, the Variable "A" is reported as "/kappa/context/main/context/A" and the C/Kernel "CheckGold" is reported as "/kappa/context/main/context/CheckGold".

For a FINISHED or CANCELED command, the current CUDA device memory allocations is also reported. The 113808 number in the above example is the size, in bytes, of device memory that has ever been allocated at the time the command completed. This number is not the same as the amount device memory in actual use—it is the accumulation of all allocations—disregarding the freeing of the device memory.

Page