#include <cnc/dist_cnc.h>
<cnc/cnc.h>
#ifdef _DIST_ # include <cnc/dist_cnc.h> #else # include <cnc/cnc.h> #endif
In "main", initialize an object CnC::dist_cnc_init< list-of-contexts > before anything else; parameters should be all context-types ever used in the program:
#ifdef _DIST_ CnC::dist_cnc_init< my_context_type_1 /*, my_context_type_2, ... */ > _dinit; #endif
If and only if your items and/or tags are non-standard data types, the compiler will notify you about the need for serialization capability. Serialization of structs/classes without pointers or virtual functions can easily be enabled using CNC_BITWISE_SERIALIZABLE( type ); others need a "serialize" method or function. See Serialization for more details.
Step instances are distributed across clients and the host. By default, they are distributed in a round-robin fashion. Note that every process can put tags (and so prescribe new step instances). The round-robin distribution decision is made locally on each process (not globally).
If the same tag is put multiple times, it might be scheduled for execution on different processes and the preserveTags attribute of tag_collections will then not have the desired effect.
To potentially get around this problem, you can provide a tuner when prescribing steps with a CnC::tag_collection. The tuner should be derived from CnC::default_tuner and provide a method called "pass_on", which takes the tag of the step and the context as arguments and has to return the process number to run the step on. To avoid the aforementioned problem, you simply need to make sure that the return value is independent of the process it is executed on. The pass_on mechanism can be used to provide any distribution strategy which can be computed locally.
struct my_tuner : public CnC::default_tuner< tag_type, context_type > { int pass_on( const tag_type & tag, context_type & ) const { return tag % 4; } };
Global variables are evil and must not be used within the execution scope of steps.
"Global" attributes of collections (e.g. size(), iteration, etc.) must not be used while steps are being executed (e.g. within the dynamic scope of step-code).
If "CNC_SOCKET_HOST" is is not a number it is interpreted as a name of a script. CnC executes the script twice: First with "-n" it expects the script to return the number of clients it will start. The second invocation is expected to launch the client processes.
There is a sample script "misc/start.sh" which you can use. Usually all you need is setting the number of clients and replacing "localhost" with the names of the machines you want the application(-clients) to be started on. It requires password-less login via ssh. It also gives some details of the start-up procedure. For windows, the script "start.bat" does the same, except that it will start the clients on the same machine without ssh or alike. Adjust the script to use your preferred remote login mechanism.
1.5.6