ВУЗ:
Составители:
Рубрика:
- 58 -
Рисунок 5.1 — Ленточная схема умножения матриц (пересылаемые ленты и вычислен-
ный блок результирующей матрицы выделены серым фоном).
// source code of MM_MPI_2.C program
// Ros Leibensperger / Blaise Barney. Converted to MPI: George L.
#include “mpi.h”
#include <stdio.h>
#define NRA 3000 /* number of rows in matrix A */
#define NCA 3000 /* number of columns in matrix A */
#define NCB 10 /* number of columns in matrix B */
#define MASTER 0 /* taskid of MASTER task */
#define FROM_MASTER 1 /* setting a message type */
#define FROM_WORKER 2 /* setting a message type */
#define M_C_W MPI_COMM_WORLD
int main(int argc, char *argv[])
{
int numtasks, /* number of tasks in partition */
taskid, /* a task identifier */
numworkers, /* number of worker tasks */
source, /* task id of message source */
dest, /* task id of message destination */
rows, /* rows of matrix A sent to each worker */
averow, extra, offset, /* used to determine rows sent to each worker */
i, j, k, rc; /* indexes */
double a[NRA][NCA], /* matrix A to be multiplied */
b[NCA][NCB], /* matrix B to be multiplied */
c[NRA][NCB], /* result matrix C */
t1,t2; // time’s momemts
MPI_Status status;
rc = MPI_Init(&argc,&argv);
rc|= MPI_Comm_size(M_C_W, &numtasks);
rc|= MPI_Comm_rank(M_C_W, &taskid);
if (rc != MPI_SUCCESS)
printf (“error initializing MPI and obtaining task ID information\n”);
else
printf (“task ID = %d\n”, taskid);
numworkers = numtasks-1;
- 58 -
Рисунок 5.1 — Ленточная схема умножения матриц (пересылаемые ленты и вычислен-
ный блок результирующей матрицы выделены серым фоном).
// source code of MM_MPI_2.C program
// Ros Leibensperger / Blaise Barney. Converted to MPI: George L.
#include “mpi.h”
#include
#define NRA 3000 /* number of rows in matrix A */
#define NCA 3000 /* number of columns in matrix A */
#define NCB 10 /* number of columns in matrix B */
#define MASTER 0 /* taskid of MASTER task */
#define FROM_MASTER 1 /* setting a message type */
#define FROM_WORKER 2 /* setting a message type */
#define M_C_W MPI_COMM_WORLD
int main(int argc, char *argv[])
{
int numtasks, /* number of tasks in partition */
taskid, /* a task identifier */
numworkers, /* number of worker tasks */
source, /* task id of message source */
dest, /* task id of message destination */
rows, /* rows of matrix A sent to each worker */
averow, extra, offset, /* used to determine rows sent to each worker */
i, j, k, rc; /* indexes */
double a[NRA][NCA], /* matrix A to be multiplied */
b[NCA][NCB], /* matrix B to be multiplied */
c[NRA][NCB], /* result matrix C */
t1,t2; // time’s momemts
MPI_Status status;
rc = MPI_Init(&argc,&argv);
rc|= MPI_Comm_size(M_C_W, &numtasks);
rc|= MPI_Comm_rank(M_C_W, &taskid);
if (rc != MPI_SUCCESS)
printf (“error initializing MPI and obtaining task ID information\n”);
else
printf (“task ID = %d\n”, taskid);
numworkers = numtasks-1;
Страницы
- « первая
- ‹ предыдущая
- …
- 56
- 57
- 58
- 59
- 60
- …
- следующая ›
- последняя »
