/**
*
* Charm Tutorial Exercise
* Key-value store, reduction, sdag
*
*
*
**/
mainmodule main {
readonly CProxy_Main mainProxy;
readonly CProxy_KeyValueStore kvstoreProxy;
readonly CProxy_KeyValueClient kvclientProxy;
readonly int N;
readonly int M;
readonly int K;
mainchare Main {
entry Main(CkArgMsg *m);
entry [reductiontarget] void finish();
};
array [1D] KeyValueClient {
entry KeyValueClient();
entry void response(int refnum, int value);
entry void run(){
serial {
for(i=0; i<K; i++){
int key = rand()%(M*N);
kvpairs[i].key = key;
}
}
/************
add code here
1. send the request for values for all the keys in the vector kvpairs
use method KeyValueStore::request(..) for this
2. the corresponding array elements of KeyValueStore Array will send
the values back by calling the KeyValueClient::response(..) that will
also have the request refnum.
save the value at the correct index (by using refnum) of the kvpairs vector
3. once all the responses have been received, do a reduction with Main::finish() as
the reduction target which will exit the program
*********/
};
};
array [1D] KeyValueStore {
entry KeyValueStore(void);
entry void request(int refnum, int k, int reqIdx);
};
};
|