#include "jacobi.h"
#include "time.h"
void initTask() {
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &commLen);
initMatrixSize();
initResIndexes();
initMatrix();
initFreePart();
initLinearOperator();
initEps();
initX();
}
static inline double getElement(size_t i, size_t j) {
return A[i*N+j];
}
static void initMatrixSize() {
MPI_Status status;
int i;
if (!rank) scanf("%d", &N);
MPI_Bcast(&N, 1, MPI_INTEGER, 0, MPI_COMM_WORLD);
}
static void initResIndexes() {
resLen = (N+commLen-1)/commLen;
resIndex = rank*resLen;
}
static void initMatrix() {
A = malloc(N*resLen*sizeof(double));
double *tA;
if (!rank) {
tA= malloc(N*commLen*resLen*sizeof(double));
int i,j;
//your system of uploading source code isn't working and I lost any hope to upload this stuf.=(
for(i=0 ; i eps) {
++iterationsCounter;
iterate();
}
if (!rank) {
endTime=MPI_Wtime();
printSolution();
totalTime = endTime-startTime;
printf("time: %ud", iterationsCounter);
printf("time: %lf", totalTime);
}
freeAll();
}
#include "stdlib.h"
#include "jacobi.h"
#include "mpi.h"
int main(int argc, char **argv) {
MPI_Init(&argc, &argv);
initTask();
solve();
MPI_Finalize();
exit(EXIT_SUCCESS);
}