To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit d8124031 authored by ahuegli's avatar ahuegli

up to date

parent 92d117d2
......@@ -20,6 +20,8 @@ void SSA_CPU::operator()()
double * const x0 = new double[numSamples];
double * const x1 = new double[numSamples];
const double reactionChannels[m*n] = {-1.0, 0.0, 0.0, -1.0, 1.0, -1.0, 0.0, 1.0};
// NUMA aware initialization (first touch)
#ifdef _OPENMP
#pragma omp parallel for
......@@ -133,8 +135,6 @@ void SSA_CPU::operator()()
double a0 = a[0]+a[1]+a[2]+a[3];
double a0 = 0.0;
// TODO: Task 1a) (STEP 1)
// - sample tau using the inverse sampling method and increment time, use uniform random numbers initialized in r48
......
......@@ -18,7 +18,22 @@ void direct(korali::Sample& k)
// - get S1 and S2
// - calculate objective function
double sse = 0.0; // TODO
int omega = 1;
int num_samples = 2000;
double T = 5.0;
double bin_dt = 0.1;
SSA_CPU ssa(omega, num_samples, T, bin_dt);
ssa.setRates(k1, k2, k3, k4);
ssa();
double s1 = ssa.getS1();
double s2 = ssa.getS2();
double s1Comp = s1 - 15.0; // S1 component
double s2Comp = s2 - 5.0; // S2 component
double sse = s1Comp*s1Comp - s2Comp*S2Comp;
k["F(x)"] = -sse;
}
......
korali @ 07b4b316
Subproject commit 07b4b31633175a50fe31a502619e5a2924387ba2
......@@ -35,19 +35,31 @@ int main(int argc, char* argv[])
int nFactors = NUM_FACTORS;
// TODO: Specify the variables factorsPerRank, initFactor and endFactor
int factorsPerRank = 0;
int initFactor = 0;
int endFactor = 0;
// TODO: Initialize a global pointer factorArray. Rank zero has to initialize the array. Do not forget to finally broadcast the global pointer to all ranks from rank 0 so that all ranks have access to the same global adress space
int factorsPerRank = ( nFactors ) / rankCount;
int initFactor = (rankId * factorsPerRank) + 1;
int endFactor = initFactor + factorsPerRank;
// TODO: Initialize a global pointer factorArray. Rank zero has to initialize the array. Do not forget to finally broadcast the global pointer to all ranks from rank 0 so that all ranks have access to the same global adress space
upcxx::global_ptr<double> factorArray;
if(rankId == 0){
factorArray = upcxx::new_array<double>(rankCount);
}
upcxx::broadcast(&factorArray, 1, 0).wait();
double pi_approx = 0.0;
for(int i = initFactor; i < endFactor; ++i){
pi_approx += FACTOR(i);
}
// TODO: After broadcasting the array, each rank needs to compute the portion of the factors it is assigned, and then \textbf{place} the result back to the \texttt{factorArray}. Do not use RPCs in this question, use the \texttt{upcxx::rput} command.
upcxx::future<> fut_all = upcxx::make_future();
upcxx::future<> fut = upcxx::rput(&pi_approx, factorArray+rankId, 1);
fut_all = upcxx::when_all(fut_all, fut);
......@@ -67,7 +79,7 @@ int main(int argc, char* argv[])
outfile.close();
// TODO ?:
upcxx::barrier();
......@@ -77,6 +89,13 @@ int main(int argc, char* argv[])
double pi_approx = 0.0;
double* locFactorArray = factorArray.local();
for(int i = 0; i < rankCount; ++i){
pi_approx += locFactorArray[i];
}
pi_approx = 4.0 * pi_approx;
......
......@@ -48,6 +48,10 @@ int main(int argc, char* argv[])
// factorArray is now initialized as a global array. (please see some lines above)
// TODO: Similarly to the divide and conquer strategy, the master needs to initialize the array with the upcxx::new_array<double> command. Then the array needs to be broadcasted so that all ranks have access and point to the shared address space.
factorArray = upcxx::new_array<double>(rankCount-1);
upcxx::broadcast(&factorArray, 1, 0).wait();
......@@ -62,6 +66,14 @@ int main(int argc, char* argv[])
double pi_approx = 0.0;
double* locFactorArray = factorArray.local();
for(int i = 0; i < rankCount-1; ++i){
pi_approx += locFactorArray[i];
}
pi_approx = 4.0 * pi_approx;
......@@ -104,12 +116,14 @@ int main(int argc, char* argv[])
void workerComputeFactor(int rankId, int factorId)
{
// TODO: Compute factor
double f = FACTOR(factorId);
// TODO: As a worker, use a RPC to update the master's factorArray with the computed factor, and notify the master that you are again available to compute by pushing your rankId to the queue
upcxx::rpc_ff(0, [](double f, int rank){
double* locArray = factorArray.local();
locArray[rank-1] += f;
workers.push(rank);
}, f, rankId);
......@@ -127,8 +141,11 @@ void master(int rankCount)
// When no rank available call progress()
while(workers.empty()) upcxx::progress();
//TODO: Whenever any worker is available, the master has to get his \texttt{workerId}, by popping out the first \texttt{workerId} from the queue of the available workers.
int workerId = workers.front();
workers.pop();
// TODO: After identifying an available worker, the master needs to send an RPC, the task that the consumer has to complete. This is no other than the workerComputeFactor(workerId, factorId)
upcxx::rpc_ff(workerId, [](int workerId, int factorId){workerComputeFactor(workerId, factorId);}, workerId, factorId);
}
// Master is notifying the workers to stop the evaluation of factors
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment