yuri648
Messages postés677Date d'inscriptionmardi 30 décembre 2008StatutMembreDernière intervention20 mai 2015
-
12 févr. 2011 à 20:17
yuri648
Messages postés677Date d'inscriptionmardi 30 décembre 2008StatutMembreDernière intervention20 mai 2015
-
12 févr. 2011 à 22:29
Bonjour,
j'essaye d'executer un programme PVM sous LINUX c la multiplication matricielle
mais je recoi ces erreur apres la compilation
mmult.o: In function 'main':
mmult.c:(.text+0x1fc): undefined reference to 'pvm_joingroup'
mmult.c:(.text+0x29f): undefined reference to 'pvm_lvgroup'
mmult.c:(.text+0x301): undefined reference to 'pvm_lvgroup'
mmult.c:(.text+0x37e): undefined reference to 'pvm_lvgroup'
mmult.c:(.text+0x409): undefined reference to 'pvm_gettid'
mmult.c:(.text+0x47d): undefined reference to 'pvm_barrier'
mmult.c:(.text+0x4e7): undefined reference to 'pvm_gettid'
mmult.c:(.text+0x60b): undefined reference to 'pvm_lvgroup'
mmult.c:(.text+0x68d): undefined reference to 'pvm_gettid'
mmult.c:(.text+0x6d5): undefined reference to 'pvm_gettid'
mmult.c:(.text+0x839): undefined reference to 'pvm_gettid'
mmult.c:(.text+0xa57): undefined reference to 'pvm_lvgroup'
voici le programme PVM / C
/*
Matrix Multiply
From PVM: Parallel Virtual Machine
A Users' Guide and Tutorial for Networked Parallel Computing
Geist et al
*/
/* defines and prototypes for the PVM library */
#include "pvm3.h"
#include <stdio.h>
/* Maximum number of children this program will spawn */
#define MAXNTIDS 100
#define MAXROW 10
void
InitBlock(float *a, float *b, float *c, int blk, int row, int col)
{
int len, ind;
int i,j;
srand(pvm_mytid());
len = blk*blk;
for (ind = 0; ind < len; ind++)
{ a[ind] = (float)(rand()%1000)/100.0; c[ind] = 0.0; }
for (i = 0; i < blk; i++) {
for (j = 0; j < blk; j++) {
if (row == col)
b[j*blk+i] = (i==j)? 1.0 : 0.0;
else
b[j*blk+i] = 0.0;
}
}
}
void
BlockMult(float* c, float* a, float* b, int blk)
{
int i,j,k;
for (i = 0; i < blk; i++)
for (j = 0; j < blk; j ++)
for (k = 0; k < blk; k++)
c[i*blk+j] += (a[i*blk+k] * b[k*blk+j]);
}
int
main(int argc, char* argv[])
{
/* number of tasks to spawn, use 3 as the default */
int ntask = 2;
/* return code from pvm calls */
int info;
/* my task and group id */
int mytid, mygid;
/* children task id array */
int child[MAXNTIDS-1];
int i, m, blksize;
/* array of the tids in my row */
int myrow[MAXROW];
float *a, *b, *c, *atmp;
int row, col, up, down;
/* find out my task id number */
mytid = pvm_mytid();
//pvm_advise(PvmRouteDirect);
pvm_setopt(PvmRoute, PvmRouteDirect);
/* check for error */
if (mytid < 0) {
/* print out the error */
pvm_perror(argv[0]);
/* exit the program */
return -1;
}
/* join the mmult group */
mygid = pvm_joingroup("mmult");
if (mygid < 0) {
pvm_perror(argv[0]); pvm_exit(); return -1;
}
/* if my group id is 0 then I must spawn the other tasks */
if (mygid == 0) {
/* find out how many tasks to spawn */
if (argc == 3) {
m = atoi(argv[1]);
blksize = atoi(argv[2]);
}
if (argc < 3) {
fprintf(stderr, "usage: mmult m blk\n");
pvm_lvgroup("mmult"); pvm_exit(); return -1;
}
/* make sure ntask is legal */
ntask = m*m;
if ((ntask < 1) || (ntask >= MAXNTIDS)) {
fprintf(stderr, "ntask = %d not valid.\n", ntask);
pvm_lvgroup("mmult"); pvm_exit(); return -1;
}
/* no need to spawn if there is only one task */
if (ntask == 1) goto barrier;
/* spawn the child tasks */
info = pvm_spawn("mmult", (char**)0, PvmTaskDefault, (char*)0,
ntask-1, child);
/* make sure spawn succeeded */
if (info != ntask-1) {
pvm_lvgroup("mmult"); pvm_exit(); return -1;
}
/* make sure all tasks have joined the group */
barrier:
info = pvm_barrier("mmult",ntask);
if (info < 0) pvm_perror(argv[0]);
/* find the tids in my row */
for (i = 0; i < m; i++)
myrow[i] = pvm_gettid("mmult", (mygid/m)*m + i);
/* allocate the memory for the local blocks */
a = (float*)malloc(sizeof(float)*blksize*blksize);
b = (float*)malloc(sizeof(float)*blksize*blksize);
c = (float*)malloc(sizeof(float)*blksize*blksize);
atmp = (float*)malloc(sizeof(float)*blksize*blksize);
/* check for valid pointers */
if (!(a && b && c && atmp)) {
fprintf(stderr, "%s: out of memory!\n", argv[0]);
free(a); free(b); free(c); free(atmp);
pvm_lvgroup("mmult"); pvm_exit(); return -1;
}
/* find my block's row and column */
row = mygid/m; col = mygid % m;
/* calculate the neighbor's above and below */
up = pvm_gettid("mmult", ((row)?(row-1):(m-1))*m+col);
down = pvm_gettid("mmult", ((row == (m-1))?col:(row+1)*m+col));
Trouvez des réponses à vos questions sur les langages, les frameworks et les astuces de codage. Échangez avec d'autres développeurs passionnés pour améliorer vos compétences en programmation et rester au fait des dernières tendances du secteur.