cns_build

Compiles a package of cell types so that it can be used to build network models. Packages must be compiled whenever files in the package directory change.

Can also produce several other outputs that help in package development. All outputs go into the package directory.

Syntax

cns_build package
cns_build package action
package
The package name. cns_build will locate the package by looking for a file called package_cns.m in your MATLAB path.

action
One of the actions in the table below. Defaults to compile.
Action Description Output Files
compile Compiles the package. Generates two MATLAB "mex" files, one for GPU execution and one for CPU execution.
package_cns_compiled_*.mex*
help Generates a text file listing all available CNS macros for each cell type.
package_cns_compiled_help.txt
info Generates a text file showing GPU compilation details for each kernel. This can be useful for determining if your kernels are written (and being compiled) efficiently. Click here for details on interpreting this file.
package_cns_compiled_cuda_info.txt
generate For the curious. Generates all the same temporary files that are normally generated during the compile process, but just leaves them in the package directory without compiling them.
package_cns_generated_*
preprocess Also for the curious. Performs the compile process up to and including the C++ preprocessor step, but does not perform the final compilation into object code. Interesting if you want to see what all the macros expand into.
package_cns_compiled_*_pre.*
clean Deletes any of the above compilation outputs from the package directory. n/a


Interpreting GPU Compilation Details

The file package_cns_compiled_cuda_info.txt, produced by the info option, will contain a section like this for every kernel:

code {
    name = _Z11_kernel_maxjjPKf9_OutTablejjjPK7ushort4PK10_LayerData
    lmem = 0
    smem = 224
    reg  = 22
    bar  = 1
    const {

The three useful pieces of information are highlighted:

  1. The type name. (In this example, "max".)

  2. The amount of local memory the kernel uses. This is a misnomer on NVIDIA's part: "local memory" in their terminology refers to memory a kernel uses for local calculations that does not fit into registers. It is actually in main GPU memory, which has high latency. You want this number to be zero. (In this example, it is.) A common way this number gets to be nonzero is when you declare local C++ arrays in the kernel. Consider using CNS's alternative fast local arrays instead.

  3. The number of registers the kernel uses. Lower is better, because it means you can make the block size larger.
The file also contains a lot of other junk which you can ignore.