Last active
June 27, 2017 21:33
-
-
Save galek/a139ade00b8ef097ea984768f2b6a0b9 to your computer and use it in GitHub Desktop.
CHILD_FINISHED_SENDED
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <time.h> | |
#include <pvm3.h> | |
#include <unistd.h> | |
#include <math.h> | |
# define SIZE 1000 | |
# define NPROCS 5 | |
using namespace std; | |
int main() | |
{ | |
int mytid, n; /* my task id */ | |
float *a,*b,*Proiz; | |
int me, nproc, master, msgtype; | |
mytid = pvm_mytid(); | |
/* Receive data from master */ | |
msgtype = 0; | |
pvm_recv(-1, msgtype); | |
/* receive portion of array to be summed */ | |
pvm_recv ( -1 , -1) ; | |
pvm_upkint (& num_data , 1 , 1) ; | |
// Сразу берем всю строку | |
a = ( float *) malloc ( SIZE * num_data * sizeof ( float ) ) ; | |
pvm_upkfloat (a , SIZE * num_data , 1) ; | |
b = ( float *) malloc ( num_data * sizeof ( float ) ) ; | |
pvm_upkfloat (b , num_data , 1) ; | |
Proiz = ( float *) malloc ( num_data * sizeof ( float ) ) ; | |
// Учти, что изначельно у нас a[i][j] тут быо | |
for (int i = 0; i < num_data ; i ++) | |
{ | |
usleep(1); // Смоделируем задержку | |
Proiz [ i ] = a [ i ] * b [ i ]; | |
} | |
/* send computed sum back to master */ | |
master = pvm_parent () ; | |
pvm_initsend ( PvmDataRaw ) ; | |
pvm_pkfloat (& Proiz , num_data , 1) ; | |
pvm_send ( master , 7) ; | |
pvm_exit () ; | |
return 0; | |
} |
Поправил все на float числа.
Поправил, что бы сразу работа была со строкой
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Не заливал версию с double числами. По приезду домой залью