AE environment variables: executable and shared libraries
You can use the register_ae function to set the executable path and to set the NZAE_EXECUTABLE_PATH environment variable. This section contains examples using AEs with AE-ENVs.
Simple C Language AE
For this example, a simple C-language AE is compiled into an executable called helloae. The AE export directory is located at /nz/export/ae. Compiling produces one version for the host and one for the SPUs:
/nz/export/ae/applications/dev/david/host/helloae
/nz/export/ae/applications/dev/david/spu/helloae
The AE environment variables point the AE system to the location of the executables:
NZAE_HOST_ONLY_NZAE_EXECUTABLE_PATH=/nz/export/ae/applications/dev/david/host/hel
loae
NZAE_SPU_ONLY_NZAE_EXECUTABLE_PATH=/nz/export/ae/applications/dev/david/spu/hello
ae
The AE-ENV key names consist of two parts: a root and a location prefix. In the previous example, the root is NZAE_EXECUTABLE_PATH. The prefixes are NZAE_HOST_ONLY and NZAE_SPU_ONLY.
A variable with the NZAE_HOST_ONLY location prefix is only visible on the host. The location prefix is stripped off and the host receives the value:
NZAE_EXECUTABLE_PATH=/nz/export/ae/applications/dev/david/host/helloae
Similarly, a variable with a NZAE_SPU_ONLY location prefix is visible only to the SPUs. Again, the location prefix is stripped off and the SPUs receive:
NZAE_EXECUTABLE_PATH=/nz/export/ae/applications/dev/david/spu/helloae
Simple C Language AE with Shared Libraries
In this example, the AE helloae uses a directory of shared libraries. Set the Linux LD_LIBRARY_PATH for the application. It can be modified because the AE runtime system also uses LD_LIBRARY_PATH for its own operation. First, place the shared libraries in the AE Export Directory Tree.
/nz/export/ae/applications/dev/david/libhost/lib*.so
/nz/export/ae/applications/dev/david/libspu/lib*.so
This code shows how to get the AE runtime system to append the directory to LD_LIBRARY_PATH:
NZAE_HOST_ONLY_NZAE_APPEND_LD_LIBRARY_PATH=/nz/export/ae/applications/dev/david/l
ibhost
NZAE_SPU_ONLY_NZAE_APPEND_LD_LIBRARY_PATH=/nz/export/ae/applications/dev/david/li
bspu
These AE-ENV definitions consist of two prefixes and a root. The root is LD_LIBRARY_PATH. The first prefix, which is required to be specified first, is the location prefix discussed above. The second is the append prefix NZAE_APPEND, which tells the AE to append this value to an existing value. If the key has no value then a new value is created. When appending, the AE system first looks for an AE-ENV of the target key name. If not found, the AE system looks in the OS process environment.
The same technique can be used to append to any environment variable, including PATH and CLASSPATH. You can use the prepend prefix, NZAE_PREPEND, to prepend to any AE-ENV or OS environment variable. The location prefix must be specified before an append or prepend prefix. The values appended or prepended are separated by the colon (:) character. The prefixes provide the AE programmer significant control over the environment where the process runs. Variable assignments are performed in a first pass. Append and prepend operations are performed in a second pass after all the assignments have been processed.