neptune 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +7 -4
- data/doc/AppControllerClient.html +12 -4
- data/doc/CommonFunctions.html +55 -42
- data/doc/Kernel.html +187 -0
- data/doc/LICENSE.html +2 -0
- data/doc/Object.html +488 -198
- data/doc/README.html +26 -5
- data/doc/bin/neptune.html +1 -1
- data/doc/created.rid +6 -6
- data/doc/index.html +20 -2
- data/doc/lib/app_controller_client_rb.html +2 -2
- data/doc/lib/common_functions_rb.html +2 -2
- data/doc/lib/neptune_rb.html +3 -1
- data/lib/app_controller_client.rb +2 -2
- data/lib/common_functions.rb +50 -24
- data/lib/neptune.rb +224 -159
- data/samples/appscale/add_appserver.rb +10 -0
- data/samples/appscale/add_database.rb +9 -0
- data/samples/appscale/add_loadbalancer.rb +9 -0
- data/samples/appscale/add_slave.rb +9 -0
- data/samples/c/compile_helloworld.rb +10 -0
- data/samples/c/helloworld/helloworld.c +6 -0
- data/samples/erlang/compile_erlang_ring.rb +10 -0
- data/samples/erlang/get_erlang_output.rb +8 -0
- data/samples/erlang/ring/Makefile +3 -0
- data/samples/erlang/ring/ring.erl +90 -0
- data/samples/erlang/run_erlang_ring.rb +6 -0
- data/samples/go/compile_hello.rb +10 -0
- data/samples/go/get_hello_output.rb +6 -0
- data/samples/go/hello/hello.go +8 -0
- data/samples/go/put_input.rb +8 -0
- data/samples/go/run_hello.rb +9 -0
- data/samples/mapreduce/expected-output.txt +7078 -0
- data/samples/mapreduce/get_mapreduce_output.rb +4 -0
- data/samples/mapreduce/hadoop-0.20.0-examples.jar +0 -0
- data/samples/mapreduce/input-10 +64 -0
- data/samples/mapreduce/input-30 +64 -0
- data/samples/mapreduce/input-7 +4 -0
- data/samples/mapreduce/map.rb +48 -0
- data/samples/mapreduce/reduce.rb +48 -0
- data/samples/mapreduce/run_java_mr.rb +14 -0
- data/samples/mapreduce/run_mapreduce.rb +13 -0
- data/samples/mapreduce/the-end-of-time.txt +11256 -0
- data/samples/mpi/Makefile +22 -0
- data/samples/mpi/MpiQueen +0 -0
- data/samples/mpi/compile_mpi_ring.rb +10 -0
- data/samples/mpi/compile_x10_nqueens.rb +8 -0
- data/samples/mpi/cpi +0 -0
- data/samples/mpi/get_mpi_output.rb +5 -0
- data/samples/mpi/get_ring_output.rb +5 -0
- data/samples/mpi/hw2.c +205 -0
- data/samples/mpi/hw2harness.c +84 -0
- data/samples/mpi/hw2harness.h +45 -0
- data/samples/mpi/powermethod +0 -0
- data/samples/mpi/ring/Makefile +2 -0
- data/samples/mpi/ring/Ring.c +76 -0
- data/samples/mpi/run_mpi_cpi.rb +10 -0
- data/samples/mpi/run_mpi_nqueens.np +6 -0
- data/samples/mpi/run_mpi_powermethod.rb +8 -0
- data/samples/mpi/run_mpi_ring.rb +12 -0
- data/samples/r/compile_hello.rb +10 -0
- data/samples/r/get_hello_output.rb +6 -0
- data/samples/r/hello/hello.r +1 -0
- data/samples/r/put_input.rb +8 -0
- data/samples/r/run_hello.rb +9 -0
- data/samples/upc/compile_upc_helloworld.rb +10 -0
- data/samples/upc/compile_upc_ring.rb +11 -0
- data/samples/upc/get_mpi_output.rb +8 -0
- data/samples/upc/helloworld/HelloWorld.c +9 -0
- data/samples/upc/helloworld/Makefile +3 -0
- data/samples/upc/ring/Makefile +3 -0
- data/samples/upc/ring/Ring.c +116 -0
- data/samples/upc/run_upc_helloworld.rb +12 -0
- data/samples/upc/run_upc_ring.rb +12 -0
- data/samples/x10/MyPowerMethod +0 -0
- data/samples/x10/MyPowerMethod.x10 +236 -0
- data/samples/x10/NQueensDist +0 -0
- data/samples/x10/NQueensDist.x10 +112 -0
- data/samples/x10/compile_x10_nqueens.rb +7 -0
- data/samples/x10/compile_x10_ring.rb +12 -0
- data/samples/x10/get_x10_output.rb +8 -0
- data/samples/x10/ring/Makefile +3 -0
- data/samples/x10/ring/Ring.x10 +28 -0
- data/samples/x10/ring/RingOld.x10 +68 -0
- data/samples/x10/run_x10_nqueens.rb +6 -0
- data/samples/x10/run_x10_powermethod.rb +7 -0
- data/samples/x10/run_x10_ring.rb +6 -0
- data/test/{tc_c.rb → integration/tc_c.rb} +2 -2
- data/test/{tc_dfsp.rb → integration/tc_dfsp.rb} +0 -0
- data/test/{tc_dwssa.rb → integration/tc_dwssa.rb} +0 -0
- data/test/{tc_erlang.rb → integration/tc_erlang.rb} +0 -0
- data/test/{tc_mapreduce.rb → integration/tc_mapreduce.rb} +0 -0
- data/test/{tc_mpi.rb → integration/tc_mpi.rb} +0 -0
- data/test/{tc_storage.rb → integration/tc_storage.rb} +0 -0
- data/test/{tc_upc.rb → integration/tc_upc.rb} +0 -0
- data/test/{tc_x10.rb → integration/tc_x10.rb} +0 -0
- data/test/{test_helper.rb → integration/test_helper.rb} +0 -0
- data/test/{ts_neptune.rb → integration/ts_neptune.rb} +2 -2
- data/test/unit/test_app_controller_client.rb +106 -0
- data/test/unit/test_common_functions.rb +106 -0
- data/test/unit/test_neptune.rb +208 -0
- data/test/unit/ts_all.rb +6 -0
- metadata +91 -15
@@ -0,0 +1 @@
|
|
1
|
+
"hello world"
|
@@ -0,0 +1,116 @@
|
|
1
|
+
#include <upc.h>
|
2
|
+
#include <upc_strict.h>
|
3
|
+
//#include <upc_relaxed.h>
|
4
|
+
#include <stdio.h>
|
5
|
+
|
6
|
+
#define NUM_MESSAGES 100
|
7
|
+
|
8
|
+
#define FROM_MASTER 0
|
9
|
+
|
10
|
+
#define size THREADS
|
11
|
+
#define rank MYTHREAD
|
12
|
+
|
13
|
+
#define MASTER(rank) (rank == 0)
|
14
|
+
#define SLAVE(rank) (!MASTER)
|
15
|
+
|
16
|
+
#define SUCCESS 0
|
17
|
+
#define FAILURE 1
|
18
|
+
|
19
|
+
#define DEBUG 0
|
20
|
+
|
21
|
+
shared int* a;
|
22
|
+
shared int* alldone;
|
23
|
+
|
24
|
+
int sendM(target, value) {
|
25
|
+
a[target] = value;
|
26
|
+
if (DEBUG) printf("[node %d] wrote value %d to location %d\n", rank, value, target);
|
27
|
+
|
28
|
+
return 0;
|
29
|
+
}
|
30
|
+
|
31
|
+
int recvM(from, value) {
|
32
|
+
int tempa = a[from];
|
33
|
+
|
34
|
+
if (DEBUG) printf("[node %d] value at location %d is currently %d (should be %d)\n", rank, from, tempa, value);
|
35
|
+
|
36
|
+
if (tempa == value) {
|
37
|
+
if (DEBUG) printf("[node %d] returns success\n", rank);
|
38
|
+
return SUCCESS;
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
if (DEBUG) printf("[node %d] returns failure\n", rank);
|
42
|
+
return FAILURE;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
int main() {
|
47
|
+
clock_t start_time, end_time;
|
48
|
+
|
49
|
+
// start timing
|
50
|
+
if (MASTER(rank)) {
|
51
|
+
start_time = clock();
|
52
|
+
}
|
53
|
+
|
54
|
+
a = (shared int*) upc_all_alloc(size, sizeof(int));
|
55
|
+
alldone = (shared int*) upc_all_alloc(1, sizeof(int));
|
56
|
+
upc_barrier;
|
57
|
+
|
58
|
+
if (MASTER(rank)) {
|
59
|
+
int i = 0;
|
60
|
+
for(i = 0; i < size; i++) {
|
61
|
+
a[i] = 0;
|
62
|
+
if (DEBUG) printf("A[%d] = %d\n", i, a[i]);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
alldone[0] = FAILURE;
|
67
|
+
upc_barrier;
|
68
|
+
|
69
|
+
int curr_msg = 1;
|
70
|
+
for(curr_msg = 1; curr_msg <= NUM_MESSAGES; curr_msg++) {
|
71
|
+
if (MASTER(rank)) a[0] = curr_msg;
|
72
|
+
int msg_send = FAILURE;
|
73
|
+
while(1) {
|
74
|
+
int received = recvM(rank, curr_msg);
|
75
|
+
if ((received == SUCCESS) && (rank + 1 == size)) {
|
76
|
+
if (DEBUG) printf("got last message\n");
|
77
|
+
alldone[0] = SUCCESS;
|
78
|
+
} else if (received == SUCCESS) {
|
79
|
+
if (msg_send == FAILURE) {
|
80
|
+
if (DEBUG) printf("[node %d] sends a message\n", rank);
|
81
|
+
sendM(rank+1, curr_msg);
|
82
|
+
msg_send = SUCCESS;
|
83
|
+
}
|
84
|
+
sleep(0.01);
|
85
|
+
}
|
86
|
+
|
87
|
+
upc_barrier;
|
88
|
+
if (alldone[0] == SUCCESS) break;
|
89
|
+
}
|
90
|
+
|
91
|
+
upc_barrier;
|
92
|
+
if (rank + 1 == size) alldone[0] = FAILURE;
|
93
|
+
upc_barrier;
|
94
|
+
}
|
95
|
+
|
96
|
+
upc_barrier;
|
97
|
+
if (DEBUG) {
|
98
|
+
int i = 0;
|
99
|
+
for(i = 0; i < size; i++) {
|
100
|
+
printf("[node %d] says A[%d] = %d\n", rank, i, a[i]);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
// end timing
|
105
|
+
if (MASTER(rank)) {
|
106
|
+
end_time = clock();
|
107
|
+
}
|
108
|
+
|
109
|
+
if (MASTER(rank)) {
|
110
|
+
double total_time = (double)(end_time - start_time) / CLOCKS_PER_SEC;
|
111
|
+
printf("Total time taken to send %d messages across %d machines was %f\n", NUM_MESSAGES, size, total_time);
|
112
|
+
}
|
113
|
+
upc_barrier;
|
114
|
+
return 0;
|
115
|
+
}
|
116
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
output = neptune (
|
3
|
+
:type => "mpi",
|
4
|
+
#@keyname = "cluster"
|
5
|
+
:code => "helloworld-compiled/HelloWorld",
|
6
|
+
:nodes_to_use => 4,
|
7
|
+
:procs_to_use => 8,
|
8
|
+
:output => "/baz/output2"
|
9
|
+
)
|
10
|
+
|
11
|
+
puts "job started? #{output[:result]}"
|
12
|
+
puts "message = #{output[:msg]}"
|
Binary file
|
@@ -0,0 +1,236 @@
|
|
1
|
+
import x10.lang.Math;
|
2
|
+
import x10.util.Timer;
|
3
|
+
|
4
|
+
public class MyPowerMethod {
|
5
|
+
|
6
|
+
static val SUCCESS = 0;
|
7
|
+
static val ERROR = 1;
|
8
|
+
|
9
|
+
static val NUM_ITERATIONS = 30;
|
10
|
+
static val EPSILON = 0.00001;
|
11
|
+
|
12
|
+
static val N = 6400;
|
13
|
+
static val P = Place.MAX_PLACES;
|
14
|
+
|
15
|
+
/*
|
16
|
+
* X vector is of size n x 1 and lives on the first processor
|
17
|
+
* is initialized to one
|
18
|
+
*/
|
19
|
+
|
20
|
+
static val R1 <: Region = (0..N-1);
|
21
|
+
static val D1 <: Dist = R1 -> Place.FIRST_PLACE;
|
22
|
+
//static val F0 <: (Point(1)) => Double = ([i]:Point(1)) => 0.0;
|
23
|
+
static val F1 <: (Point(1)) => Double = ([i]:Point(1)) => 1.0;
|
24
|
+
static val X <: DistArray[Double] = DistArray.make[Double](D1, F1);
|
25
|
+
|
26
|
+
/*
|
27
|
+
* A matrix is of size n x n and lives on all processors
|
28
|
+
* each proc gets a block of size (n/p) x n where p is the
|
29
|
+
* number of processors
|
30
|
+
* is initialized to zero
|
31
|
+
*/
|
32
|
+
|
33
|
+
static val R2 <: Region = (0..N-1) * (0..N-1);
|
34
|
+
static val D2 <: Dist = Dist.makeBlock(R2);
|
35
|
+
static val F2 <: (Point(2)) => Double = ([i, j]:Point(2)) => 0.0;
|
36
|
+
static val A <: DistArray[Double] = DistArray.make[Double](D2, F2);
|
37
|
+
|
38
|
+
public static def norm() {
|
39
|
+
var theNorm : Double = 0.0;
|
40
|
+
|
41
|
+
for (var index : Int = 0; index < N; index++) {
|
42
|
+
theNorm += (X(index) * X(index));
|
43
|
+
}
|
44
|
+
|
45
|
+
return Math.sqrt(theNorm);
|
46
|
+
}
|
47
|
+
|
48
|
+
public static def matVec() {
|
49
|
+
// new way - should be nice and fast
|
50
|
+
val D0 <: Dist = Dist.makeBlock(R1);
|
51
|
+
val F0 <: (Point(1)) => Double = ([i]:Point(1)) => 0.0;
|
52
|
+
val XTemp = DistArray.make[Double](D0, F0);
|
53
|
+
|
54
|
+
finish {
|
55
|
+
for (place in A.dist().places()) {
|
56
|
+
async at (place) {
|
57
|
+
val DHere <: Dist = R1 -> here;
|
58
|
+
val XCopy = DistArray.make[Double](DHere, F0);
|
59
|
+
for (var i : Int = 0; i < N; i++) {
|
60
|
+
val index = i;
|
61
|
+
XCopy(index) = at (Place.FIRST_PLACE) { X(index) };
|
62
|
+
}
|
63
|
+
|
64
|
+
//Console.OUT.printf("my place id is %d, next id is %d\n", place.id, place.next().id);
|
65
|
+
|
66
|
+
var startRow : Int = place.id * N / P;
|
67
|
+
var endRow : Int = (place.id + 1) * N / P;
|
68
|
+
//if (endRow == 0) { endRow = startRow + N / P; }
|
69
|
+
|
70
|
+
//Console.OUT.printf("start row is %d, end row is %d\n", startRow, endRow);
|
71
|
+
|
72
|
+
for (var row : Int = startRow; row < endRow; row++) {
|
73
|
+
var sum : Double = 0;
|
74
|
+
for (var col : Int = 0; col < N; col++) {
|
75
|
+
val inner = col;
|
76
|
+
sum += (A(row,col) * XCopy(col));
|
77
|
+
//val XPoint = at (Place.FIRST_PLACE) { X(inner) };
|
78
|
+
//sum += (A(row,col) * XPoint);
|
79
|
+
//Console.OUT.printf("A(%d,%d) * X(%d) = %d * %d\n", row, col, inner, A(row,col), XPoint);
|
80
|
+
}
|
81
|
+
XTemp(row) = sum;
|
82
|
+
//Console.OUT.printf("setting x(%d) to %f\n", row, sum);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
for (var index : Int = 0; index < N; index++) {
|
89
|
+
val row = Point.make(index);
|
90
|
+
val correctPlace = XTemp.dist.apply(row);
|
91
|
+
val XNew = at (correctPlace) { XTemp(row) };
|
92
|
+
X(index) = XNew;
|
93
|
+
//Console.OUT.printf("actually setting x(%d) to %f\n", index, XNew);
|
94
|
+
}
|
95
|
+
|
96
|
+
// old way - slow on big sizes of N
|
97
|
+
/*
|
98
|
+
val D0 <: Dist = R1 -> here;
|
99
|
+
val F0 <: (Point(1)) => Double = ([i]:Point(1)) => 0.0;
|
100
|
+
val XTemp = DistArray.make[Double](D0, F0);
|
101
|
+
for (var outer : Int = 0; outer < N; outer++) {
|
102
|
+
val sum : Array[Double](1) = new Array[Double](1);
|
103
|
+
sum(0) = 0;
|
104
|
+
for (var inner : Int = 0; inner < N; inner++) {
|
105
|
+
val inner1DPoint = Point.make(inner);
|
106
|
+
val inner2DPoint = Point.make(outer,inner);
|
107
|
+
val correctPlace = A.dist.apply(inner2DPoint);
|
108
|
+
val XPoint = X(inner1DPoint);
|
109
|
+
sum(0) += at (correctPlace) {
|
110
|
+
(A(inner2DPoint) * XPoint)
|
111
|
+
};
|
112
|
+
//Console.OUT.printf("[out] sum is now %f\n", sum(0));
|
113
|
+
}
|
114
|
+
XTemp(outer) = sum(0);
|
115
|
+
//Console.OUT.printf("XTemp(%d) is now %f\n", outer, sum(0));
|
116
|
+
}
|
117
|
+
|
118
|
+
//Console.OUT.println("After Matvec:");
|
119
|
+
for (var index : Int = 0; index < N; index++) {
|
120
|
+
X(index) = XTemp(index);
|
121
|
+
//Console.OUT.printf("x[%d] = %f\n", index, X(index));
|
122
|
+
}
|
123
|
+
*/
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
|
127
|
+
public static def powerMethod() {
|
128
|
+
var xNorm : Double = 0;
|
129
|
+
|
130
|
+
for (var iter : Int = 0; iter < NUM_ITERATIONS; iter++) {
|
131
|
+
xNorm = norm();
|
132
|
+
Console.OUT.printf("At iteration %d, the norm of x is %f\n", iter, xNorm);
|
133
|
+
|
134
|
+
for (var index : Int = 0; index < N; index++) {
|
135
|
+
val myIndex = index;
|
136
|
+
val myXNorm = xNorm;
|
137
|
+
X(myIndex) = X(myIndex) / myXNorm;
|
138
|
+
//Console.OUT.printf("x[%d] = %f\n", index, X(index));
|
139
|
+
}
|
140
|
+
Console.OUT.printf("entering matvec\n");
|
141
|
+
matVec();
|
142
|
+
}
|
143
|
+
|
144
|
+
for (var index : Int = 0; index < N; index++) {
|
145
|
+
val myIndex = index;
|
146
|
+
val myXNorm = xNorm;
|
147
|
+
//Console.OUT.printf("final x[%d] = %f\n", index, X(index));
|
148
|
+
}
|
149
|
+
|
150
|
+
return xNorm;
|
151
|
+
}
|
152
|
+
|
153
|
+
public static def generateMatrix() {
|
154
|
+
if (N % P != 0) {
|
155
|
+
Console.OUT.println("n doesn't divide p evenly. Please enter n and try again.");
|
156
|
+
return ERROR;
|
157
|
+
}
|
158
|
+
|
159
|
+
// put the value N at the diagonals
|
160
|
+
finish {
|
161
|
+
for (var i : Int = 0; i < N; i++) {
|
162
|
+
val diagonal = Point.make(i, i);
|
163
|
+
val correctPlace = A.dist.apply(diagonal);
|
164
|
+
async at (correctPlace) {
|
165
|
+
A(diagonal) = N;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
return SUCCESS;
|
171
|
+
}
|
172
|
+
|
173
|
+
public static def verify() {
|
174
|
+
val answer = Math.sqrt(N + 0.0f);
|
175
|
+
for (var i : Int = 0; i < N; i++) {
|
176
|
+
val diff = Math.abs(X(i) - answer);
|
177
|
+
if (diff > EPSILON) {
|
178
|
+
Console.OUT.printf("X(%d)'s value, %f, was too far away from %f\n", i, X(i), answer);
|
179
|
+
return ERROR;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
return SUCCESS;
|
184
|
+
}
|
185
|
+
|
186
|
+
public static def printArray[T](array:DistArray[T]) {
|
187
|
+
for (place in array.dist.places()) {
|
188
|
+
at (place) {
|
189
|
+
for (point in array.dist | here ) {
|
190
|
+
val myPoint : String = "[" + point(0) + ", " + point(1) + "] ->" + array(point);
|
191
|
+
Console.OUT.println(myPoint);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
|
199
|
+
public static def main(args:Array[String](1)) {
|
200
|
+
//Console.OUT.println("str(x) = " + X);
|
201
|
+
//printArray(X);
|
202
|
+
//Console.OUT.println("str(a) = " + A);
|
203
|
+
//printArray(A);
|
204
|
+
|
205
|
+
Console.OUT.println("n is " + N);
|
206
|
+
Console.OUT.println("p is " + P);
|
207
|
+
|
208
|
+
val retval = generateMatrix();
|
209
|
+
if (retval == ERROR) {
|
210
|
+
Console.OUT.println("ERROR");
|
211
|
+
return;
|
212
|
+
}
|
213
|
+
|
214
|
+
//Console.OUT.println("str(x) = " + X);
|
215
|
+
//printArray(X);
|
216
|
+
//Console.OUT.println("str(a) = " + A);
|
217
|
+
//printArray(A);
|
218
|
+
|
219
|
+
val startTime = Timer.milliTime();
|
220
|
+
val spectralRadius = powerMethod();
|
221
|
+
val endTime = Timer.milliTime();
|
222
|
+
val totalTime = (endTime - startTime) / 1000.0;
|
223
|
+
|
224
|
+
Console.OUT.printf("The spectral radius is %f\n", spectralRadius);
|
225
|
+
Console.OUT.printf("It took %f seconds\n", totalTime);
|
226
|
+
|
227
|
+
//printArray(X);
|
228
|
+
|
229
|
+
val result = verify();
|
230
|
+
if (result == SUCCESS) {
|
231
|
+
Console.OUT.printf("Yay, we win!\n");
|
232
|
+
} else {
|
233
|
+
Console.OUT.printf("Boo, we lose... again\n");
|
234
|
+
}
|
235
|
+
}
|
236
|
+
}
|