質問編集履歴
1
添付ファイルを間違えました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,8 +14,6 @@
|
|
14
14
|
|
15
15
|
```vect_test.cpp
|
16
16
|
|
17
|
-
|
18
|
-
|
19
17
|
#include <mpi.h>
|
20
18
|
|
21
19
|
#include <iostream>
|
@@ -48,57 +46,93 @@
|
|
48
46
|
|
49
47
|
|
50
48
|
|
51
|
-
for(int l=0; l<3; l++){
|
52
|
-
|
53
|
-
if(l==0){
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
49
|
+
MPI_Init(&argc, &argv);
|
58
|
-
|
50
|
+
|
59
|
-
|
51
|
+
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
|
60
|
-
|
52
|
+
|
61
|
-
|
53
|
+
MPI_Comm_size(MPI_COMM_WORLD, &p);
|
62
|
-
|
63
|
-
|
64
|
-
|
54
|
+
|
55
|
+
|
56
|
+
|
65
|
-
|
57
|
+
w.resize(n_value);
|
66
|
-
|
58
|
+
|
67
|
-
|
59
|
+
for(auto &ref :w) {
|
68
|
-
|
60
|
+
|
69
|
-
|
61
|
+
ref.resize(n_visible);
|
70
|
-
|
62
|
+
|
71
|
-
|
63
|
+
for(auto &ref2 :ref){
|
72
|
-
|
64
|
+
|
73
|
-
|
65
|
+
ref2.resize(n_hidden);
|
74
|
-
|
66
|
+
|
75
|
-
|
67
|
+
for(auto &ref3 :ref2){
|
76
|
-
|
68
|
+
|
77
|
-
|
69
|
+
ref3 = 0.0;
|
78
|
-
|
70
|
+
|
79
|
-
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
vect3d.resize(n_value);
|
80
|
+
|
81
|
+
for(auto &ref :vect3d) {
|
82
|
+
|
83
|
+
ref.resize(n_visible);
|
84
|
+
|
85
|
+
for(auto &ref2 :ref){
|
86
|
+
|
87
|
+
ref2.resize(n_hidden);
|
88
|
+
|
89
|
+
for(auto &ref3 :ref2){
|
90
|
+
|
91
|
+
ref3 = (double)my_rank;
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
if(my_rank==0){
|
102
|
+
|
103
|
+
for(i=0; i<n_value; i++){
|
104
|
+
|
105
|
+
for(j=0; j<n_visible; j++){
|
106
|
+
|
107
|
+
for(k=0; k<n_hidden; k++){
|
108
|
+
|
109
|
+
printf("w[%d][%d][%d]=%f \n", i, j, k, w[i][j][k]);
|
80
110
|
|
81
111
|
}
|
82
112
|
|
83
113
|
}
|
84
114
|
|
85
|
-
|
86
|
-
|
87
|
-
vect3d.resize(n_value);
|
88
|
-
|
89
|
-
for(auto &ref :vect3d) {
|
90
|
-
|
91
|
-
ref.resize(n_visible);
|
92
|
-
|
93
|
-
for(auto &ref2 :ref){
|
94
|
-
|
95
|
-
ref2.resize(n_hidden);
|
96
|
-
|
97
|
-
for(auto &ref3 :ref2){
|
98
|
-
|
99
|
-
ref3 = 1.0 +(double)my_rank;
|
100
|
-
|
101
|
-
|
115
|
+
}
|
116
|
+
|
117
|
+
printf("\n");
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
MPI_Reduce(&vect3d[0][0][0], &w[0][0][0], n_value * n_visible * n_hidden, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
if(my_rank==0){
|
128
|
+
|
129
|
+
for(i=0; i<n_value; i++){
|
130
|
+
|
131
|
+
for(j=0; j<n_visible; j++){
|
132
|
+
|
133
|
+
for(k=0; k<n_hidden; k++){
|
134
|
+
|
135
|
+
printf("w[%d][%d][%d]=%f \n", i, j, k, w[i][j][k]);
|
102
136
|
|
103
137
|
}
|
104
138
|
|
@@ -106,53 +140,7 @@
|
|
106
140
|
|
107
141
|
}
|
108
142
|
|
109
|
-
|
110
|
-
|
111
|
-
if(my_rank==0 && l==0){
|
112
|
-
|
113
|
-
for(i=0; i<n_value; i++){
|
114
|
-
|
115
|
-
for(j=0; j<n_visible; j++){
|
116
|
-
|
117
|
-
for(k=0; k<n_hidden; k++){
|
118
|
-
|
119
|
-
printf("w[%d][%d][%d]=%f \n", i, j, k, w[i][j][k]);
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
143
|
+
printf("\n");
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
MPI_Reduce(&vect3d[0][0][0], &w[0][0][0], n_value * n_visible * n_hidden, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
if(my_rank==0){
|
138
|
-
|
139
|
-
for(i=0; i<n_value; i++){
|
140
|
-
|
141
|
-
for(j=0; j<n_visible; j++){
|
142
|
-
|
143
|
-
for(k=0; k<n_hidden; k++){
|
144
|
-
|
145
|
-
printf("w[%d][%d][%d]=%f \n", i, j, k, w[i][j][k]);
|
146
|
-
|
147
|
-
}
|
148
|
-
|
149
|
-
}
|
150
|
-
|
151
|
-
}
|
152
|
-
|
153
|
-
printf("\n");
|
154
|
-
|
155
|
-
}
|
156
144
|
|
157
145
|
}
|
158
146
|
|