public static void ReInitializeAccum() { for (int ThreadNo = 0; ThreadNo < SALSAUtility.ThreadCount; ThreadNo++) { ChisqFirstandSecond.Zeromember(ref LocalAccum[ThreadNo]); } ChisqFirstandSecond.Zeromember(ref SummedoverThreadsAccum); ChisqFirstandSecond.Zeromember(ref SummedoverProcessesAccum); }
// End ReInitializeAccum() public static void AddupChisqContributions(Desertwind TotalSolution) { // Sum over Threads int NumberParms = SummedoverThreadsAccum.VectorSize; int SecondSize = SummedoverThreadsAccum.SecondSize; for (int ThreadNo = 0; ThreadNo < SALSAUtility.ThreadCount; ThreadNo++) { SummedoverThreadsAccum.chisq += LocalAccum[ThreadNo].chisq; for (int iparm = 0; iparm < NumberParms; iparm++) { SummedoverThreadsAccum.first[iparm] += LocalAccum[ThreadNo].first[iparm]; } for (int iparm = 0; iparm < SecondSize; iparm++) { SummedoverThreadsAccum.second[iparm] += LocalAccum[ThreadNo].second[iparm]; } } // Sum over MPI Processes ChisqFirstandSecond UsethisAccum = SummedoverThreadsAccum; if (SALSAUtility.MPI_Size > 1) { UsethisAccum = SummedoverProcessesAccum; SummedoverProcessesAccum.chisq = SALSAUtility.MPI_communicator.Allreduce(SummedoverThreadsAccum.chisq, Operation <double> .Add); SummedoverProcessesAccum.first = SALSAUtility.MPI_communicator.Allreduce(SummedoverThreadsAccum.first, Operation <double> .Add); SummedoverProcessesAccum.second = SALSAUtility.MPI_communicator.Allreduce( SummedoverThreadsAccum.second, Operation <double> .Add); } // Put into Hotsun Form TotalSolution.Chisquared = UsethisAccum.chisq; Hotsun.zerocr = UsethisAccum.chisq; int linearcount = 0; for (int iparm1 = 0; iparm1 < NumberParms; iparm1++) { TotalSolution.first[iparm1][0] = UsethisAccum.first[iparm1]; for (int iparm2 = iparm1; iparm2 < NumberParms; iparm2++) { double tmp = UsethisAccum.second[linearcount]; linearcount++; TotalSolution.FullMatrix[iparm1, iparm2][0, 0] = tmp; TotalSolution.FullMatrix[iparm2, iparm1][0, 0] = tmp; TotalSolution.ExactFullMatrix[iparm1, iparm2][0, 0] = tmp; TotalSolution.ExactFullMatrix[iparm2, iparm1][0, 0] = tmp; } } // SALSAUtility.SALSAPrint(0, "Second Deriv " + TotalSolution.FullMatrix[5, 6][0, 0].ToString("E4")); }
public static void Zeromember(ref ChisqFirstandSecond Instance) { Instance.chisq = 0.0; for (int iparm = 0; iparm < Instance.VectorSize; iparm++) { Instance.first[iparm] = 0.0; } for (int iparm = 0; iparm < Instance.SecondSize; iparm++) { Instance.second[iparm] = 0.0; } }
public static void SetupGenericManxcat() { LocalAccum = new ChisqFirstandSecond[SALSAUtility.ThreadCount]; int NumberParms = Hotsun.npar; for (int ThreadNo = 0; ThreadNo < SALSAUtility.ThreadCount; ThreadNo++) { LocalAccum[ThreadNo] = new ChisqFirstandSecond(NumberParms); } SummedoverThreadsAccum = new ChisqFirstandSecond(NumberParms); SummedoverProcessesAccum = new ChisqFirstandSecond(NumberParms); Hotsun.Number_VectorParameters = Hotsun.npar; Hotsun.ParameterVectorDimension = 1; Hotsun.DecomposeParameters = false; SALSAUtility.sequentialBLAS = true; Hotsun.fullmatrixset = true; }