diff --git a/ae b/ae new file mode 100644 index 0000000000000000000000000000000000000000..7c2b92a3597a14ecf06b3df422e39c0782c054e9 --- /dev/null +++ b/ae @@ -0,0 +1,9 @@ +0 4 0 0 0 0 0 8 0 +4 0 8 0 0 0 0 11 0 +0 8 0 7 0 4 0 0 2 +0 0 7 0 9 14 0 0 0 +0 0 0 9 0 10 0 0 0 +0 0 4 14 10 0 2 0 0 +0 0 0 0 0 2 0 1 6 +8 11 0 0 0 0 1 0 7 +0 0 2 0 0 0 6 7 0 \ No newline at end of file diff --git a/dijkstra.c b/dijkstra.c index 308ec1535f6d1b5942493df3b83875d4e7bcca57..e5e12d466466df266490a0ce4258ac84d9ae485c 100644 --- a/dijkstra.c +++ b/dijkstra.c @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) { } else { for (int vertex = (rank - 1) * numOfTaskPerProcess; vertex < (rank - 1) * numOfTaskPerProcess + numOfTaskPerProcess; vertex++) { long* dataSend = dijkstra(graph, vertex); - MPI_Send(dataSend, N, MPI_LONG, destinationRank, tag, MPI_COMM_WORLD); + MPI_Send(dataSend, N, MPI_LONG, 0, tag, MPI_COMM_WORLD); } } diff --git a/mpi.c b/mpi.c new file mode 100644 index 0000000000000000000000000000000000000000..861df396de8e4bb7483d12e10e0c3c19d61c6d0c --- /dev/null +++ b/mpi.c @@ -0,0 +1,144 @@ +#include "mpi.h" +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <limits.h> + +int N = 1000; + +int getmin_index(long **graph, bool pickedVertices[N], int sourceVertex) { + int minDistance = CHAR_MAX; + int min_index = -1; + + for (int j = 0; j < N; j++) { + if (!pickedVertices[j] && graph[sourceVertex][j] <= minDistance) { + minDistance = graph[sourceVertex][j]; + min_index = j; + } + } + return min_index; +} + +void print(long **graph){ + printf("Matrix: \n"); + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + printf("%ld ", graph[i][j]); + } + printf("\n"); + } +} + +void dijkstra(long** graph, int sourceVertex) { + + // Distance from single source to all of the nodes + bool pickedVertices[N]; + + for (int vertex = 0; vertex < N; vertex++) { + pickedVertices[vertex] = false; + } + + for (int i = 0; i < N - 1; i++) { + // Get minimum distance + int min_index = getmin_index(graph, pickedVertices, sourceVertex); + + // Mark the vertice as picked + pickedVertices[min_index] = true; + + // Update distance value + for (int vertex = 0; vertex < N; vertex++) { + if ((!pickedVertices[vertex]) && + (graph[min_index][vertex]) && + (graph[sourceVertex][min_index] != INT_MAX) && + (graph[sourceVertex][min_index] + graph[min_index][vertex] < graph[sourceVertex][vertex])) { + + graph[sourceVertex][vertex] = graph[sourceVertex][min_index] + graph[min_index][vertex]; + } + } + } + return; +} + +int main(int argc, char *argv[]) { + + // Get matrix size from argument vector in , convert to int + N = strtol(argv[1], NULL, 10); + + long** graph; + graph = (long**) malloc(sizeof(long*) * N); + for (int i = 0; i < N; ++i) + { + graph[i] = (long*) malloc(sizeof(long) * N); + } + int numtasks, rank, dest, source, rc, count, tag=1; + double start_time, end_time, total_time; + + srand(13517115); + // Fill the matrix with rand() function + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + // Mod by 100 so the result won't be too big. + graph[i][j] = rand() % 100; + } + } + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (!(i == j || graph[i][j])){ + graph[i][j] = INT_MAX; + } + } + } + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (i == j){ + graph[i][j] = 0; + } + } + } + + MPI_Status Stat; + MPI_Init(&argc,&argv); + MPI_Comm_size(MPI_COMM_WORLD, &numtasks); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Barrier(MPI_COMM_WORLD); + start_time = MPI_Wtime(); + + int jobs = N/(numtasks-1); + long* dataRecv; + int destinationRank = 0; + count = 0; + if (!rank){ + dataRecv = (long*) malloc(sizeof(long) * N*jobs); + while(count<numtasks-1){ + MPI_Recv(dataRecv, N*jobs, MPI_LONG, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &Stat); + printf("Received from process %d ", Stat.MPI_SOURCE); + for (int i = 0; i < N*jobs; ++i) + { + graph[Stat.MPI_SOURCE*jobs-jobs][i] = dataRecv[i]; + } + count++; + } + free(dataRecv); + } + else{ + for (int i = rank*jobs-jobs; i < rank*jobs; ++i) + { + dijkstra(graph, i); + // printf("Print job %d from rank %d\n", i, rank); + } + MPI_Send(graph[rank*jobs-jobs], N*jobs, MPI_LONG, destinationRank, tag, MPI_COMM_WORLD); + } + + MPI_Barrier(MPI_COMM_WORLD); + end_time = MPI_Wtime(); + total_time = end_time - start_time; + MPI_Finalize(); + if (rank == 0) { + printf("%f\n", total_time); + } + for (int i = 0; i < N; ++i) + { + free(graph[i]); + } + free(graph); +} \ No newline at end of file diff --git a/reset.c b/reset.c index caa26b1ec93ed2eb058f00114fcf8453550b3f64..971b1368b0edeec8feaf7db0d37216308f4a7d82 100644 --- a/reset.c +++ b/reset.c @@ -6,8 +6,8 @@ int N = 10; -long getVertexWithMinDistance(long dist[], bool pickedVertices[]) { - long minDistance = LONG_MAX; +int getVertexWithMinDistance(int dist[], bool pickedVertices[]) { + int minDistance = INT_MAX; int vertexWithMinDistance = -1; for (int vertex = 0; vertex < N; vertex++) { @@ -20,27 +20,18 @@ long getVertexWithMinDistance(long dist[], bool pickedVertices[]) { } -long* dijkstra(int graph[N][N], int sourceVertex) { +void dijkstra(int graph[N][N], int sourceVertex) { // Distance from single source to all of the nodes - long *dist = (long*) malloc(sizeof(long) * N); bool pickedVertices[N]; for (int vertex = 0; vertex < N; vertex++) { - if (vertex == sourceVertex) { - dist[vertex] = 0; - } else { - // Initialize all distance to be infinity. - dist[vertex] = LONG_MAX; - } pickedVertices[vertex] = false; } - dist[sourceVertex] = 0; - for (int i = 0; i < N - 1; i++) { // Get minimum distance - int vertexWithMinDistance = getVertexWithMinDistance(dist, pickedVertices); + int vertexWithMinDistance = getVertexWithMinDistance(graph[i], pickedVertices); // Mark the vertice as picked pickedVertices[vertexWithMinDistance] = true; @@ -49,17 +40,17 @@ long* dijkstra(int graph[N][N], int sourceVertex) { for (int vertex = 0; vertex < N; vertex++) { if ((!pickedVertices[vertex]) && (graph[vertexWithMinDistance][vertex]) && - (dist[vertexWithMinDistance] != LONG_MAX) && - (dist[vertexWithMinDistance] + graph[vertexWithMinDistance][vertex] < dist[vertex])) { - // Change dist[] - dist[vertex] = dist[vertexWithMinDistance] + graph[vertexWithMinDistance][vertex]; + (graph[i][vertexWithMinDistance] + graph[vertexWithMinDistance][vertex] < graph[i][vertex])) { + + graph[i][vertex] = graph[i][vertexWithMinDistance] + graph[vertexWithMinDistance][vertex]; } } } - return dist; + return; } int main(int argc, char *argv[]) { + int graph[N][N]; int rank, numtasks; double start_time, end_time, total_time; MPI_Status Stat; @@ -68,7 +59,6 @@ int main(int argc, char *argv[]) { MPI_Comm_rank(MPI_COMM_WORLD, &rank); start_time = MPI_Wtime(); - int graph[N][N]; srand(13517115); // Fill the matrix with rand() function for (int i = 0; i < N; i++) { @@ -93,6 +83,7 @@ int main(int argc, char *argv[]) { MPI_Finalize(); if (rank == 0) { + MPI_Recv(&dataRecv, N, MPI_INT, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &Stat); printf("%f\n", total_time); } diff --git a/ser.c b/ser.c new file mode 100644 index 0000000000000000000000000000000000000000..028dd9c05b2e3224793a62871fee52d2fc829283 --- /dev/null +++ b/ser.c @@ -0,0 +1,98 @@ +#include "mpi.h" +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <limits.h> + +int N = 100; + +int getmin_index(short graph[N][N], bool pickedVertices[N], int sourceVertex) { + int minDistance = CHAR_MAX; + int min_index = -1; + + for (int j = 0; j < N; j++) { + if (!pickedVertices[j] && graph[sourceVertex][j] <= minDistance) { + minDistance = graph[sourceVertex][j]; + min_index = j; + } + } + return min_index; +} + +void print(short graph[N][N]){ + printf("Matrix: \n"); + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + printf("%d ", graph[i][j]); + } + printf("\n"); + } +} + +void dijkstra(short graph[N][N], int sourceVertex) { + + // Distance from single source to all of the nodes + bool pickedVertices[N]; + + for (int vertex = 0; vertex < N; vertex++) { + pickedVertices[vertex] = false; + } + + for (int i = 0; i < N - 1; i++) { + // Get minimum distance + int min_index = getmin_index(graph, pickedVertices, sourceVertex); + + // Mark the vertice as picked + pickedVertices[min_index] = true; + + // Update distance value + for (int vertex = 0; vertex < N; vertex++) { + if ((!pickedVertices[vertex]) && + (graph[min_index][vertex]) && + (graph[sourceVertex][min_index] != INT_MAX) && + (graph[sourceVertex][min_index] + graph[min_index][vertex] < graph[sourceVertex][vertex])) { + + graph[sourceVertex][vertex] = graph[sourceVertex][min_index] + graph[min_index][vertex]; + } + } + } + return; +} + +int main(int argc, char *argv[]) { + + // Get matrix size from argument vector in , convert to int + N = strtol(argv[1], NULL, 10); + + short graph[N][N]; + + srand(13517115); + // Fill the matrix with rand() function + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + // Mod by 100 so the result won't be too big. + graph[i][j] = rand() % 100; + } + } + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (!(i == j || graph[i][j])){ + graph[i][j] = CHAR_MAX; + } + } + } + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (i == j){ + graph[i][j] = 0; + } + } + } + + for (int i = 0; i < N; ++i) + { + dijkstra(graph, i); + printf("%d\n", i); + } + print(graph); +} \ No newline at end of file diff --git a/sr.c b/sr.c new file mode 100644 index 0000000000000000000000000000000000000000..d66d98a2f8ac2f3ef59d267146c7f6a81fc6f236 --- /dev/null +++ b/sr.c @@ -0,0 +1,64 @@ + +// Copyright www.computing.llnl.gov +#include "mpi.h" +#include <stdio.h> + + +void clean(int arr[10][10]){ + for (int i = 0; i < 10; ++i) + { + for (int j = 0; j < 10; ++j) + { + arr[i][j] = 99; + } + } +} +int main(int argc, char *argv[]) { +int numtasks, rank, dest, source, rc, count, tag=1; +int inmsg[10][10], outmsg[10][10]; + +for (int i = 0; i < 10; i++) +{ + for (int j = 0; j < 10; j++) + { + outmsg[i][j] = 10*i+j; + } +} + +MPI_Status Stat; +MPI_Init(&argc,&argv); +MPI_Comm_size(MPI_COMM_WORLD, &numtasks); +MPI_Comm_rank(MPI_COMM_WORLD, &rank); +if (rank == 0) { + dest = 1; + source = 1; + rc = MPI_Send(&outmsg[5], 50, MPI_INT, dest, tag, MPI_COMM_WORLD); + rc = MPI_Recv(&inmsg[5], 50, MPI_INT, source, tag, MPI_COMM_WORLD, &Stat); + for (int i = 5; i < 10; i++) + { + for (int j = 0; j < 10; j++) + { + printf("%d\n", inmsg[i][j]); + } + } +} +else if (rank == 1) { + dest = 0; + source = 0; + rc = MPI_Recv(&inmsg[5], 50, MPI_INT, source, tag, MPI_COMM_WORLD, &Stat); + printf("%s\n", "pass"); + for (int i = 5; i < 10; i++) + { + for (int j = 0; j < 10; j++) + { + printf("%d\n", inmsg[i][j]); + } + } + clean(inmsg); + rc = MPI_Send(&inmsg[5], 50, MPI_INT, dest, tag, MPI_COMM_WORLD); +} +rc = MPI_Get_count(&Stat, MPI_INT, &count); +printf("Task %d: Received %d char(s) from task %d with tag %d \n", +rank, count, Stat.MPI_SOURCE, Stat.MPI_TAG); +MPI_Finalize(); +} diff --git a/test/a b/test/a new file mode 100644 index 0000000000000000000000000000000000000000..f8967160b9e47a6d6c53cf8c51647889cf0a7138 Binary files /dev/null and b/test/a differ diff --git a/test/a.c b/test/a.c new file mode 100644 index 0000000000000000000000000000000000000000..c30647dd89e442170f607fba3b423580b3c147ac --- /dev/null +++ b/test/a.c @@ -0,0 +1,66 @@ +// Copyright 2012 www.mpitutorial.com +// Program yang menghitung rata-rata dari array secara paralel menggunakan Scatter dan Gather. +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <mpi.h> +#include <assert.h> +float *create_rand_nums(int num_elements) { + float *rand_nums = (float *)malloc(sizeof(float) * num_elements); + assert(rand_nums != NULL); + int i; + for (i = 0; i < num_elements; i++) { +rand_nums[i] = (rand() / (float)RAND_MAX); + } + return rand_nums; +} +float compute_avg(float *array, int num_elements) { + float sum = 0.f; + int i; + for (i = 0; i < num_elements; i++) { +sum += array[i]; + } + return sum / num_elements; +} +int main(int argc, char** argv) { + if (argc != 2) { +fprintf(stderr, "Usage: avg num_elements_per_proc\n"); +exit(1); + } + int num_elements_per_proc = atoi(argv[1]); + srand(time(NULL)); + MPI_Init(NULL, NULL); + int world_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); + int world_size; + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + float *rand_nums = NULL; + if (world_rank == 0) { +rand_nums = create_rand_nums(num_elements_per_proc * world_size); + } + float *sub_rand_nums = (float *)malloc(sizeof(float) * +num_elements_per_proc); + assert(sub_rand_nums != NULL); + MPI_Scatter(rand_nums, num_elements_per_proc, MPI_FLOAT, sub_rand_nums, +num_elements_per_proc, MPI_FLOAT, 0, MPI_COMM_WORLD); + float sub_avg = compute_avg(sub_rand_nums, num_elements_per_proc); + float *sub_avgs = NULL; + if (world_rank == 0) { +sub_avgs = (float *)malloc(sizeof(float) * world_size); +assert(sub_avgs != NULL); + } + MPI_Gather(&sub_avg, 1, MPI_FLOAT, sub_avgs, 1, MPI_FLOAT, 0, +MPI_COMM_WORLD); + if (world_rank == 0) { +float avg = compute_avg(sub_avgs, world_size); +printf("Avg of all elements is %f\n", avg); + } + if (world_rank == 0) { +free(rand_nums); +free(sub_avgs); + } + free(sub_rand_nums); + MPI_Barrier(MPI_COMM_WORLD); + MPI_Finalize(); +} + diff --git a/test/aingcupu/.Xdefaults b/test/aingcupu/.Xdefaults new file mode 100644 index 0000000000000000000000000000000000000000..abdc96a5c3a309fb794898532b2462c272393e7e --- /dev/null +++ b/test/aingcupu/.Xdefaults @@ -0,0 +1,30 @@ +! xscreensaver --------------------------------------------------------------- + +!font settings +xscreensaver.Dialog.headingFont: -*-dina-bold-r-*-*-10-*-*-*-*-*-*-* +xscreensaver.Dialog.bodyFont: -*-dina-medium-r-*-*-10-*-*-*-*-*-*-* +xscreensaver.Dialog.labelFont: -*-dina-medium-r-*-*-10-*-*-*-*-*-*-* +xscreensaver.Dialog.unameFont: -*-dina-medium-r-*-*-10-*-*-*-*-*-*-* +xscreensaver.Dialog.buttonFont: -*-dina-bold-r-*-*-10-*-*-*-*-*-*-* +xscreensaver.Dialog.dateFont: -*-dina-medium-r-*-*-10-*-*-*-*-*-*-* +xscreensaver.passwd.passwdFont: -*-dina-bold-r-*-*-10-*-*-*-*-*-*-* +!general dialog box (affects main hostname, username, password text) +xscreensaver.Dialog.foreground: #EDEDED +xscreensaver.Dialog.background: #202020 +xscreensaver.Dialog.topShadowColor: #202024 +xscreensaver.Dialog.bottomShadowColor: #202024 +xscreensaver.Dialog.Button.foreground: #EDEDFF +xscreensaver.Dialog.Button.background: #444 +!username/password input box and date text colour +xscreensaver.Dialog.text.foreground: #EDEDFF +xscreensaver.Dialog.text.background: #444 +xscreensaver.Dialog.internalBorderWidth:24 +xscreensaver.Dialog.borderWidth: 0 +xscreensaver.Dialog.shadowThickness: 2 +!timeout bar (background is actually determined by Dialog.text.background) +xscreensaver.passwd.thermometer.foreground: #A9B7C4 +xscreensaver.passwd.thermometer.background: #202020 +xscreensaver.passwd.thermometer.width: 8 +!datestamp format--see the strftime(3) manual page for details +xscreensaver.dateFormat: %I:%M%P %a %b %d, %Y + diff --git a/test/aingcupu/.bash_history b/test/aingcupu/.bash_history new file mode 100644 index 0000000000000000000000000000000000000000..5f2d540bb9b0692b6ab0c1d25b23f7cf6bf751e9 --- /dev/null +++ b/test/aingcupu/.bash_history @@ -0,0 +1,669 @@ +ls +lscpu +htop +exit +top +exit +top +nano +nano mpi_hostfile +ls +nano hellompi.c +mpicc hellompi.c -o a +nano share +ls +nano share +chmod +x share +mv a asd +ls +./share +ls +scp asd 13517109@167.205.35.151 +rm -rf 13517109@167.205.35.151 +ls +rm -rf 13517109@167.205.35.152 +rm -rf 13517109@167.205.35.153 +rm -rf 13517109@167.205.35.154 +rm -rf 13517109@167.205.35.155 +nano share +./share +ls +mpirun -np 6 --hostfile mpi_hostfile asd +top +ls +nano run +chmod +x run +./run +nano run +./run +ls +top +./run +ls +top +ls +nano copas.c +mpicc copas.c -o asd +./share +./run +nano copas.c +rm copas.c +nano c.c +nano comp +chmod +x comp +./comp +./share +./run +nano all +chmod +x all +./all +ls +exit +ls +rm share.save +ls +exit +./all +exit +./all +ls +cd /.ssh +cd ~/.ssh +ls +cd +~ls +ls +ssh-keygen -t ed25519 -C "13517109@std.stei.itb.ac.id" +exit +ls +git +ls +mpicc +ls +nano comp +./all +ls +nano comp +mpicc c.c +./all +mpicc c.c -o asd 10 +ls +nano comp +nano run +./all +mpirun -np 1 asd 10 +nano run +./all +nano run +./run 1 +./run 10 +nano all +./all 10 +nano cop +chmod +x cop +./cop +./all 10 +./cop +./all +nano run +nano all +ls +./cop +./all 1 10 +./comp +ls +./comp +./run 1 +./run 1 10 +top +htop +ks +ls +./cop +./all 5 +./all 5 10 +ls +mpirun -np 6 asd 1 10 10 +mpirun -np 6 asd 10 10 +mpirun -np 6 asd 10000000 1000000 +mpirun -np 6 asd 1000 1000 +top +./cop +./run 6 100 +./all 6 100 +./run 6 100 +mpirun -np 5 asd 100 +mpirun -np 5 asd 10000 +mpirun -np 5 asd 100000 +nano run +./run 4 10 +./run 4 10000 +./run 2 10000 +ls +./cop +./all 6 100 +./all 6 1000 +./cop +./all +./all 1 +./all 5 +./all 3 +./cop +./all 1 +./all 1 10 +nano all +./cop +ls +./comp +./cop +./all +./all 1 +./cop +./all +./all 1 +./cop +./all 1 +./cop +nano all +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./cop +./all +./run 6 +./share +./run 6 +./run 1 +nano all +./cop +./all +./run +./run 6 +ls +./cop +./all +./run 2 +./run 3 +./run 2 +./cop +./all 2 x +./run 2 +./run 2 x +./run 2 'x' +./run 2 "X" +./cop +./comp +./cop +./comp +./cop +./comp +./share +./run 2 +./cop +./COP +./cop +./all 2 +nano all +./all +./all 2 +./run 2 +./cop +./all 2 +./cop +./all 2 +./cop +./all 2 +./COP +./cop +./all 2 +./cop +./all 2 +./cop +./comp +./cop +./comp +./all 2 +// Copyright www.computing.llnl.gov +#include "mpi.h" +#include <stdio.h> +int main(int argc, char *argv[]) { +int numtasks, rank, dest, source, rc, count, tag=1; +int inmsg[10], outmsg[10][10]; +for (int i = 0; i < 10; ++i) +{ for (int j = 0; j < 10; ++i) +{ it(&argc,&argv); +MPI_Comm_size(MPI_COMM_WORLD, &numtasks); +MPI_Comm_rank(MPI_COMM_WORLD, &rank); +if (rank == 0) { +dest = 1; +source = 1; +rc = MPI_Send(&outmsg, 100, MPI_INT, dest, tag, MPI_COMM_WORLD); +rc = MPI_Recv(&inmsg, 100, MPI_INT, source, tag, MPI_COMM_WORLD, &Stat); +for (int i = 0; i < 10; ++i) +{ t j = 0; j < 10; ++i) +{ tf("%d\n", inmsg[i][j]); +outmsg[i][j] = 10*i+j; +} +else if (rank == 1) { +dest = 0; +./co[ +./cop +./all 2 +./cop +./all 2 +./cop +./all 2 +./cop +./all +./all 2 +./cop +./all 2 +./cop +./all 2 +./cop +./comp +./all 2 +./cop +./all 1 +./cop +./comp +./share +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./COP +./cop +./COP +./cop +./comp +././cop +./comp +./run 1 +./cop +./comp +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./cmp +./comp +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./COP +./cop +./comp +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +././cop +./comp +./cop +./comp +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run1 +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./run 1 +./cop +./comp +./cop +./comp +./cop +./comp +./cop +./com +./comp +./run 6 +./cop +./comp +./run 6 +./all 6 +./cop +./all 6 +./cop +./comp +./all 6 +nano run +nano all +./cop +./all 6 100 +./all 6 10 +./all 6 100 +./all 6 50 +./all 6 10 +./run 6 10 +./run 6 20 +./run 6 10 +./run 2 10 +./run 2 9 +./run 4 9 +./run 6 100 +./run 5 100 +./cop +#include "mpi.h" +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <limits.h> +int N = 100; +int getmin_index(int graph[N][N], bool pickedVertices[N], int sourceVertex) { +./cop +./all 6 100 +./cop +./comp +./share +./run 6 100 +./run 6 9 +./cop +./comp +./share +./cop +./comp +./share +./run 6 1000 +./cop +./comp +./share +./run 6 100 +./cop +./comp +./share +./run 6 100 +./run 6 1000 +./run 6 500 +./run 6 1000 +./cop +./all 6 100 +./all 6 500 +./run 6 1000 +./cop +./all 6 100 +./cop +./comp +./cop +./comp +./share +./run 6 100 +./run 6 10 +./cop +./comp +./share +./run 6 10 +./cop +./all 6 100 +./cop +./all 6 100 +./run 6 100 +./run 6 500 +./cop +./all 6 100 +./run 6 100 +./run 6 500 +./run 6 1000 +nano run +#include "mpi.h" +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <limits.h> +int N = 100; +int getmin_index(long graph[N][N], bool pickedVertices[N], int sourceVertex) { +mpirun -np 6 --hostfile mpi_hostfile asd 1000 +mpirun -np 6 --hostfile mpi_hostfile asd 1000 --bind-to core:overload-allowed +mpirun -np 6 --hostfile mpi_hostfile asd 1000 --verbose +./cop +./all 6 100 +./run 6 500 +./cop +./all 6 10 +./cop +./all 6 9 +./share +./run 4 9 +./cop +./comp +./share +./run 4 9 +./cop +./comp +./cop +./comp +./share +./run 4 9 +./run 2 9 +./cop +./comp +./share +./run 2 9 +./cop +./comp +./share +./run 2 9 +./cop +./comp +./share +./run 2 9 +./run 4 9 +nano c.c +./all 6 100 +./run 2 9 +./cop +./comp +./share +./run 6 100 +./cop +./comp +./share +./run 2 9 +./cop +./comp +./share +./run 2 9 +./run 4 9 +./cop +./comp +./share +./run 2 9 +./run 4 9 +./cop +./comp +./share +./run 6 0 +./run 6 100 +./run 6 1000 +./cop +./comp +./cop +./comp +./cop +./comp +./cop +./comp +./share +./run 2 9 +./run 4 9 +./run 6 1000 +./run 6 5000 +./cop +./comp +./cop +./comp +./share +./run 6 100 +./run 6 1000 +./cop +./comp +./share +./run 6 100 +./run 6 1000 +./cop +./comp +./share +./run 6 100 +./run 6 1000 +./cop +./share +./run 6 100 +./run 6 1000 +./run 6 5000 +./run 6 1000 +./run 6 3000 +./run 2 1000 +./cop +./comp +./run 1 9 +./cop +top +./cop +./comp +./run 1 9 +exit +ulimit -a +exit +ulimit -s 40000 +ulimit -a +ulimit -s 400000 +ulimit -s 80000 +ulimit -a +ulimit -s 60000 +ulimit -s 50000 +ulimit -s 40000 +./cop +./comp +./run 1 10 +./run 1 100 +./run 1 1000 +./run 1 3000 +./run 1 5000 +./cop +./comp +./run 1 5000 +./cop +./comp +./cop +./comp +./cop +./comp +./cop +./comp +./cop +./comp +./run 1 +top +htop +./cop +./comp +./run 1 +./run 1 1000 +./run 2 1000 +./run 6 1000 +./cop +./comp +./share +./run 6 1000 +./cop +./comp +./share +./run 6 5000 +./cop +./comp +./share +./run 6 5000 +nano mpi_hostfile +./cop +./comp +./cop +./comp +./share +./run 5 5000 +nano mpi_hostfile +./cop +./comp +./share +./run 6 5000 +ls +cd .. +ls +cd josal +cd 13517115 +ls -ola +ls +cd 13517109 +ls .. +exit diff --git a/test/aingcupu/.bash_logout b/test/aingcupu/.bash_logout new file mode 100644 index 0000000000000000000000000000000000000000..de4f5f75d7ccd3a5b62bd2ce683ed678a5cb72c2 --- /dev/null +++ b/test/aingcupu/.bash_logout @@ -0,0 +1,7 @@ +# ~/.bash_logout: executed by bash(1) when login shell exits. + +# when leaving the console clear the screen to increase privacy + +if [ "$SHLVL" = 1 ]; then + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q +fi diff --git a/test/aingcupu/.bashrc b/test/aingcupu/.bashrc new file mode 100644 index 0000000000000000000000000000000000000000..b488fcc4cee656840d7a756298456eaa243b3e46 --- /dev/null +++ b/test/aingcupu/.bashrc @@ -0,0 +1,117 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi diff --git a/test/aingcupu/.cache/motd.legal-displayed b/test/aingcupu/.cache/motd.legal-displayed new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/test/aingcupu/.config/Trolltech.conf b/test/aingcupu/.config/Trolltech.conf new file mode 100644 index 0000000000000000000000000000000000000000..ebabedd431130457b1410d6560f41a29d334e825 --- /dev/null +++ b/test/aingcupu/.config/Trolltech.conf @@ -0,0 +1,5 @@ +[Qt] +font="Noto Sans,9,-1,5,50,0,0,0,0,0" +style=GTK+ +doubleClickInterval=400 +cursorFlashTime=1200 diff --git a/test/aingcupu/.config/libreoffice/4/user/registrymodifications.xcu b/test/aingcupu/.config/libreoffice/4/user/registrymodifications.xcu new file mode 100644 index 0000000000000000000000000000000000000000..d87d2ea6feeec97ef2224d1ddc2136c292c3d4f9 --- /dev/null +++ b/test/aingcupu/.config/libreoffice/4/user/registrymodifications.xcu @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<oor:items xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +<item oor:path="/org.openoffice.Office.Common/Misc"><prop oor:name="SymbolStyle" oor:op="fuse"><value>elementary</value></prop></item> +</oor:items> diff --git a/test/aingcupu/.profile b/test/aingcupu/.profile new file mode 100644 index 0000000000000000000000000000000000000000..d89ea5a6e83a2956d7461b547fa0d7d68103b9c9 --- /dev/null +++ b/test/aingcupu/.profile @@ -0,0 +1,27 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi diff --git a/test/aingcupu/.ssh/asd b/test/aingcupu/.ssh/asd new file mode 100644 index 0000000000000000000000000000000000000000..c366166ba932e3cabb63fab9ac6d33583841447b --- /dev/null +++ b/test/aingcupu/.ssh/asd @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAxh7hf1JJARM42PNkLexgi+5PxgMvgbQxwr0Yk0OvojzJ+0Bq +aTRiuUn515lUFWjp0Y9vv91gGU67Rq/G41GgyA4jI3VYJAM/3WnJWZivWcckA3b9 +yOcFY+hhPvffvhk4+B0L495ZQZreGV09FTG3fp6aoGzsWy0WtFO6wKRFLklppCUy +arGe52LpnjxTBUjkikL34wvj2GtwyEXfw3tS3L7kFDXCWGp1z9HaL+BFb/lBSFny +w7asWubxaBsv6AmPw6jPdCvtT75b5ts0hHmVUQfb8T1neCaVgawKCxWAT4ZUnhaV +64PWq2Ob+CCBpS3n0tw371v6O/1Sa5w7uYsp9QIDAQABAoIBAB08W1xVgS5mbsId +EJByTED59s2qlK0YMSuiiejZWSagv9GSzOEfeN4M25CEMNND+xUQjJYMjezOIHaq +47eRyR8cbvUBkPMng5ohzTOqg13FNDxKp+KorLP0i70mCN9di3mZl7KVkihLOTEX +ADeLcZ9+uiSoTiyaN7p+jJV26DqPGhlSnBqUtFsoJTv7I1IZ9F3TJwFIrU2/O7cu +9U1CaYyUA7BBr9H2kdnM7HVQDXAxgXttgQiztIFV/eVAb8PNM2JPkCfiUfYclvJe +1EfeMTbCfy0f5jUXMhkLJyTLQylSwPio6bqujB5+V4MZRqN4o8g7DTRvG8IAEe4b +JktF6oECgYEA89qvWAYaflSbluI8Xw+fVN7TNV78XBYxgiIA+IDjVt2pTtUb3PmH +xMtHulfbksIbyon83sxG2FQ82rvKMOeD46TwyuyHYw6YO36T+4zE3arw8XGpcPmT +8FXnJ9YxvRtyj+eJjvBLjuD90GslxrPXBqkZIQtSDN+hb6w4zRS7/5UCgYEAz/0P +Ue4w7L88hqP0UwKgNGCdt8HTX3VyTZAl62kJeFtflqsyxs5YGEVYpLiwlH7vBctI +IJZ0UqKeJOGsRG3Lf2WphpiSTkKQU4YQW4vuLvsYX6Re2n0NpoPAbnouA7lVfOL4 +3ADZz6NeCfvfIMhvOd7alYPBf2yd2mDOSNvPaOECgYBAAKi+8LMpbyl7G5v+00nd +a7KBspGH1edeoXAhySpiFUGnyDVM9U1WMIh99ytRRJMowLjW/USm6M0kF9/EoC80 +o4jzqcsLC7yW+Oz8PAE7sO8WX9+6IDddAB7wjL53ROn3rSykkJs0QAc+GbFLis4o +GF/ZFXCOom9rsQcjhIqnVQKBgQCMNohebloTMDTIe70ZPPrtdHi+yW8Kum1tNpEp +q2zT8510QEOB3NdsvUst+Mgpw4y1dj5Qob0XfENqj6yHkREP+GQZtb9j/OG5PPbI +EIRoraPXzkKXvpg2Ojm/AKUGo6mrAIROJFCx9utNhbv9KMI63C61ftYyZfHgp0RJ +v82KYQKBgQC+J+0/7WernN6JhXa0nrDrQ+jDdpLWWf9ALqbxp4QgFaEb2Mcv4uJS +FLrfBDpKxfkZl618u5i0mpeOtVIsXXiv4lJku0VMnNisZlJAD409ENuNbpSn3KkK +NUK9wAScTvCU62c8pANYXSCC885dHsveptwZvDV+xC2ldSx0riTP3Q== +-----END RSA PRIVATE KEY----- diff --git a/test/aingcupu/.ssh/asd.pub b/test/aingcupu/.ssh/asd.pub new file mode 100644 index 0000000000000000000000000000000000000000..cbcbf72cebf5da1a591f2ea2311540cdf84515bf --- /dev/null +++ b/test/aingcupu/.ssh/asd.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGHuF/UkkBEzjY82Qt7GCL7k/GAy+BtDHCvRiTQ6+iPMn7QGppNGK5SfnXmVQVaOnRj2+/3WAZTrtGr8bjUaDIDiMjdVgkAz/daclZmK9ZxyQDdv3I5wVj6GE+99++GTj4HQvj3llBmt4ZXT0VMbd+npqgbOxbLRa0U7rApEUuSWmkJTJqsZ7nYumePFMFSOSKQvfjC+PYa3DIRd/De1LcvuQUNcJYanXP0dov4EVv+UFIWfLDtqxa5vFoGy/oCY/DqM90K+1Pvlvm2zSEeZVRB9vxPWd4JpWBrAoLFYBPhlSeFpXrg9arY5v4IIGlLefS3DfvW/o7/VJrnDu5iyn1 ftn@FtN diff --git a/test/aingcupu/.ssh/authorized_keys b/test/aingcupu/.ssh/authorized_keys new file mode 100644 index 0000000000000000000000000000000000000000..dc27eeb3a15382fb768417c9120e11a9889aa64c --- /dev/null +++ b/test/aingcupu/.ssh/authorized_keys @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFlg/T/xmHb9nEVZClpzeLvCxLNrtzCdLd9rzIT3ItWH55PVbLi2Mjzin2z7QqcHZ02iI0wV9f8hJHV1YzzEm9SxpmeN9RchawvIcIo2xw2Of/PKyFEVrfMjF8+TCEoT0yht6BGsLXOCssufvCxlH9sA39nOneWEJHMLXNSZGGvwu09oox6OzfAZNELLP9cNLRCjnMFR0/Tw7O5rvO6biR8Gv1J8DfI73emGHRLjeu3T1Y25feyduNwj8HtlP9UQaUzLZ3Zd2SMS8tFbryS9/RUg1xFAlr2/q1/eR25iIa3xnAZndwSJHOp45NhHmk0dKeIMcRBox+R+xHMQIZygEH ftn@FtN diff --git a/test/aingcupu/.ssh/id_ed25519 b/test/aingcupu/.ssh/id_ed25519 new file mode 100644 index 0000000000000000000000000000000000000000..39e082e17cc66027b4b106c7dfacee16f2aaf448 --- /dev/null +++ b/test/aingcupu/.ssh/id_ed25519 @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACDI8XClk5QmpuJ6ejmM8kUSXxFij/poozutaryBlxB6PwAAAKCNsH+qjbB/ +qgAAAAtzc2gtZWQyNTUxOQAAACDI8XClk5QmpuJ6ejmM8kUSXxFij/poozutaryBlxB6Pw +AAAECMjyGwyOafIEDqs0mcGy0myoQSWW/Yl72swphjs9HbgcjxcKWTlCam4np6OYzyRRJf +EWKP+mijO61qvIGXEHo/AAAAGzEzNTE3MTA5QHN0ZC5zdGVpLml0Yi5hYy5pZAEC +-----END OPENSSH PRIVATE KEY----- diff --git a/test/aingcupu/.ssh/id_ed25519.pub b/test/aingcupu/.ssh/id_ed25519.pub new file mode 100644 index 0000000000000000000000000000000000000000..420a23fd03facf9e9f428234e8db25899384fd0d --- /dev/null +++ b/test/aingcupu/.ssh/id_ed25519.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMjxcKWTlCam4np6OYzyRRJfEWKP+mijO61qvIGXEHo/ 13517109@std.stei.itb.ac.id diff --git a/test/aingcupu/.ssh/id_rsa b/test/aingcupu/.ssh/id_rsa new file mode 100644 index 0000000000000000000000000000000000000000..e4a34e4d9595cdf21b8dea3bf5bf82f0016ea4b5 --- /dev/null +++ b/test/aingcupu/.ssh/id_rsa @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAxZYP0/8Zh2/ZxFWQpac3i7wsSza7cwnS3fa8yE9yLVh+eT1W +y4tjI84p9s+0KnB2dNoiNMFfX/ISR1dWM8xJvUsaZnjfUXIWsLyHCKNscNjn/zys +hRFa3zIxfPkwhKE9MobegRrC1zgrLLn7wsZR/bAN/Zzp3lhCRzC1zUmRhr8LtPaK +Mejs3wGTRCyz/XDS0Qo5zBUdP08Ozua7zum4kfBr9SfA3yO93phh0S43rt09WNuX +3snbjcI/B7ZT/VEGlMy2d2XdkjEvLRW68kvf0VINcRQJa9v6tf3kduYiGt8ZwGZ3 +cEiRzqeOTYR5pNHSniDHEQaMfkfsRzECGcoBBwIDAQABAoIBAEO0hR32xw+y0yNE +0rkA0LbQNzlauubTke8/UjctiglhzozK6Qf8bm9hgN2zFKCKQv0NljUPohflgj/x +/HbpZMc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vBvwn5QoZDn0g13WQ9y +eKdEDN34BkQBsl69y2qQEU4A5VI9phGLA2iVT6Qju3IKRO1w7SY= +-----END RSA PRIVATE KEY----- diff --git a/test/aingcupu/.ssh/id_rsa.pub b/test/aingcupu/.ssh/id_rsa.pub new file mode 100644 index 0000000000000000000000000000000000000000..dc27eeb3a15382fb768417c9120e11a9889aa64c --- /dev/null +++ b/test/aingcupu/.ssh/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFlg/T/xmHb9nEVZClpzeLvCxLNrtzCdLd9rzIT3ItWH55PVbLi2Mjzin2z7QqcHZ02iI0wV9f8hJHV1YzzEm9SxpmeN9RchawvIcIo2xw2Of/PKyFEVrfMjF8+TCEoT0yht6BGsLXOCssufvCxlH9sA39nOneWEJHMLXNSZGGvwu09oox6OzfAZNELLP9cNLRCjnMFR0/Tw7O5rvO6biR8Gv1J8DfI73emGHRLjeu3T1Y25feyduNwj8HtlP9UQaUzLZ3Zd2SMS8tFbryS9/RUg1xFAlr2/q1/eR25iIa3xnAZndwSJHOp45NhHmk0dKeIMcRBox+R+xHMQIZygEH ftn@FtN diff --git a/test/aingcupu/.ssh/known_hosts b/test/aingcupu/.ssh/known_hosts new file mode 100644 index 0000000000000000000000000000000000000000..967ffb8852d21685ac8781e17e08c5c57107ec4d --- /dev/null +++ b/test/aingcupu/.ssh/known_hosts @@ -0,0 +1,15 @@ +|1|TpSFBPgs5x8HcpGvwEWplm4nt5A=|aBV/XRAMiNh6ZoVgqL+7qsHwWL0= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPewY1WIwySjYsd3YPCLcag3IQ+r5laEPfNg/yJLFs/9FVNQCHaUUijviSnMhxhcuVhD0+lXt5jdpO6XITEpf/U= +|1|mklDAxMbJE9Q+mdRe5bUZNNnQvY=|0Rv2mFkvyc26cNAgrZTcqUyAwaw= ssh-rsa AAAAB3N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rIckUgZ07B5/8uhnzlzpLHmVVstzNVes= +|1|SC9HxFx6cKW/9YLIDGKT2/HHG3U=|xPhnJQEkcMUDQfoWSHLE3d2cuXU= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILudAQYmgk4XJruuiQ50QTFaMlipymzYUszXCWKM4snQ diff --git a/test/aingcupu/.xscreensaver b/test/aingcupu/.xscreensaver new file mode 100644 index 0000000000000000000000000000000000000000..e4c7ad36432aab9d95c529d0508311aac3967ade --- /dev/null +++ b/test/aingcupu/.xscreensaver @@ -0,0 +1,2 @@ +mode: blank + diff --git a/test/aingcupu/a.out b/test/aingcupu/a.out new file mode 100644 index 0000000000000000000000000000000000000000..a84164bd8b199af692c5d8060ebe228dc19aa2ad Binary files /dev/null and b/test/aingcupu/a.out differ diff --git a/test/aingcupu/all b/test/aingcupu/all new file mode 100644 index 0000000000000000000000000000000000000000..155d756992c75563f4e0afa62717a071b0c8d186 --- /dev/null +++ b/test/aingcupu/all @@ -0,0 +1,3 @@ +./comp +./share +./run $1 $2 diff --git a/test/aingcupu/asd b/test/aingcupu/asd new file mode 100644 index 0000000000000000000000000000000000000000..580c8afdf71ca9773dce7015333a82aaef9bfd14 Binary files /dev/null and b/test/aingcupu/asd differ diff --git a/test/aingcupu/c.c b/test/aingcupu/c.c new file mode 100644 index 0000000000000000000000000000000000000000..2a08db54ab7cdc0d5b5550aad130b1500db3b2f7 --- /dev/null +++ b/test/aingcupu/c.c @@ -0,0 +1,144 @@ +#include "mpi.h" +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <limits.h> + +int N = 1000; + +int getmin_index(long **graph, bool pickedVertices[N], int sourceVertex) { + int minDistance = CHAR_MAX; + int min_index = -1; + + for (int j = 0; j < N; j++) { + if (!pickedVertices[j] && graph[sourceVertex][j] <= minDistance) { + minDistance = graph[sourceVertex][j]; + min_index = j; + } + } + return min_index; +} + +void print(long **graph){ + printf("Matrix: \n"); + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + printf("%ld ", graph[i][j]); + } + printf("\n"); + } +} + +void dijkstra(long** graph, int sourceVertex) { + + // Distance from single source to all of the nodes + bool pickedVertices[N]; + + for (int vertex = 0; vertex < N; vertex++) { + pickedVertices[vertex] = false; + } + + for (int i = 0; i < N - 1; i++) { + // Get minimum distance + int min_index = getmin_index(graph, pickedVertices, sourceVertex); + + // Mark the vertice as picked + pickedVertices[min_index] = true; + + // Update distance value + for (int vertex = 0; vertex < N; vertex++) { + if ((!pickedVertices[vertex]) && + (graph[min_index][vertex]) && + (graph[sourceVertex][min_index] != INT_MAX) && + (graph[sourceVertex][min_index] + graph[min_index][vertex] < graph[sourceVertex][vertex])) { + + graph[sourceVertex][vertex] = graph[sourceVertex][min_index] + graph[min_index][vertex]; + } + } + } + return; +} + +int main(int argc, char *argv[]) { + + // Get matrix size from argument vector in , convert to int + N = strtol(argv[1], NULL, 10); + + long** graph; + graph = (long**) malloc(sizeof(long*) * N); + for (int i = 0; i < N; ++i) + { + graph[i] = (long*) malloc(sizeof(long) * N); + } + int numtasks, rank, dest, source, rc, count, tag=1; + double start_time, end_time, total_time; + + srand(13517115); + // Fill the matrix with rand() function + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + // Mod by 100 so the result won't be too big. + graph[i][j] = rand() % 100; + } + } + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (!(i == j || graph[i][j])){ + graph[i][j] = INT_MAX; + } + } + } + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (i == j){ + graph[i][j] = 0; + } + } + } + + MPI_Status Stat; + MPI_Init(&argc,&argv); + MPI_Comm_size(MPI_COMM_WORLD, &numtasks); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Barrier(MPI_COMM_WORLD); + start_time = MPI_Wtime(); + + int jobs = N/(numtasks-1); + long* dataRecv; + int destinationRank = 0; + count = 0; + if (!rank){ + dataRecv = (long*) malloc(sizeof(long) * N*jobs); + while(count<numtasks-1){ + MPI_Recv(dataRecv, N*jobs, MPI_LONG, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &Stat); + printf("Received from process %d ", Stat.MPI_SOURCE); + for (int i = 0; i < N*jobs; ++i) + { + graph[Stat.MPI_SOURCE*jobs-jobs][i] = dataRecv[i]; + } + count++; + } + free(dataRecv); + } + else{ + for (int i = rank*jobs-jobs; i < rank*jobs; ++i) + { + dijkstra(graph, i); + // printf("Print job %d from rank %d\n", i, rank); + } + MPI_Send(graph[rank*jobs-jobs], N*jobs, MPI_LONG, destinationRank, tag, MPI_COMM_WORLD); + } + + MPI_Barrier(MPI_COMM_WORLD); + end_time = MPI_Wtime(); + total_time = end_time - start_time; + MPI_Finalize(); + if (rank == 0) { + printf("%f\n", total_time); + } + for (int i = 0; i < N; ++i) + { + free(graph[i]); + } + free(graph); +} diff --git a/test/aingcupu/comp b/test/aingcupu/comp new file mode 100644 index 0000000000000000000000000000000000000000..e4d3168d4b21d767dd8c17faba85b36351a5d2f7 --- /dev/null +++ b/test/aingcupu/comp @@ -0,0 +1 @@ +mpicc c.c -o asd diff --git a/test/aingcupu/cop b/test/aingcupu/cop new file mode 100644 index 0000000000000000000000000000000000000000..46104c33146a701a97f80d9fef18a4c7e74aa2a2 --- /dev/null +++ b/test/aingcupu/cop @@ -0,0 +1,2 @@ +rm c.c +nano c.c diff --git a/test/aingcupu/hellompi.c b/test/aingcupu/hellompi.c new file mode 100644 index 0000000000000000000000000000000000000000..af1dd579d5a9f8b5c6ee4ddb56b6c205ce2a4a34 --- /dev/null +++ b/test/aingcupu/hellompi.c @@ -0,0 +1,17 @@ + +#include "mpi.h" +#include <stdio.h> +int main(int argc,char *argv[]) { + int numtasks, rank; + char processor_name[MPI_MAX_PROCESSOR_NAME]; + int name_len; + MPI_Status Stat; + MPI_Init(&argc,&argv); + MPI_Comm_size(MPI_COMM_WORLD, &numtasks); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Get_processor_name(processor_name, &name_len); + printf("Hello from processor %s, task %d of %d, \n", + processor_name, rank, numtasks); + MPI_Finalize(); +} + diff --git a/test/aingcupu/mpi_hostfile b/test/aingcupu/mpi_hostfile new file mode 100644 index 0000000000000000000000000000000000000000..c2bdfe63f9245d60eb2d3dd6c9891da4aaeb2de1 --- /dev/null +++ b/test/aingcupu/mpi_hostfile @@ -0,0 +1,7 @@ +#daftar host +localhost +167.205.35.151 +167.205.35.152 +167.205.35.153 +167.205.35.154 +167.205.35.155 diff --git a/test/aingcupu/run b/test/aingcupu/run new file mode 100644 index 0000000000000000000000000000000000000000..11955d4ddf1286645b8060552ec4ed8eafa552c0 --- /dev/null +++ b/test/aingcupu/run @@ -0,0 +1 @@ +mpirun -np $1 --hostfile mpi_hostfile asd $2 diff --git a/test/aingcupu/share b/test/aingcupu/share new file mode 100644 index 0000000000000000000000000000000000000000..79186e81ea81362fdea1a5b5750c7733ca0c3580 --- /dev/null +++ b/test/aingcupu/share @@ -0,0 +1,5 @@ +scp asd 13517109@167.205.35.151:~ +scp asd 13517109@167.205.35.152:~ +scp asd 13517109@167.205.35.153:~ +scp asd 13517109@167.205.35.154:~ +scp asd 13517109@167.205.35.155:~ diff --git a/test/br.c b/test/br.c new file mode 100644 index 0000000000000000000000000000000000000000..3d5a0324e2ff7c8192c5210fc7cbb49806770705 --- /dev/null +++ b/test/br.c @@ -0,0 +1,65 @@ +// Copyright 2011 www.mpitutorial.com +// Comparison of MPI_Bcast with the my_bcast function +#include <stdio.h> +#include <stdlib.h> +#include <mpi.h> +#include <assert.h> +void my_bcast(void* data, int count, MPI_Datatype datatype, int root, + MPI_Comm communicator) { + int world_rank; + MPI_Comm_rank(communicator, &world_rank); + int world_size; + MPI_Comm_size(communicator, &world_size); + if (world_rank == root) { + // If we are the root process, send our data to everyone + int i; + for (i = 0; i < world_size; i++) { + if (i != world_rank) { + MPI_Send(data, count, datatype, i, 0, communicator); + } + } + } else { + // If we are a receiver process, receive the data from the root + MPI_Recv(data, count, datatype, root, 0, communicator, MPI_STATUS_IGNORE); + } +} +int main(int argc, char** argv) { + if (argc != 3) { + fprintf(stderr, "Usage: compare_bcast num_elements num_trials\n"); + exit(1); + } + int num_elements = atoi(argv[1]); + int num_trials = atoi(argv[2]); + MPI_Init(NULL, NULL); + int world_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); + double total_my_bcast_time = 0.0; + double total_mpi_bcast_time = 0.0; + int i; + int* data = (int*)malloc(sizeof(int) * num_elements); + assert(data != NULL); + for (i = 0; i < num_trials; i++) { + // Time my_bcast + // Synchronize before starting timing + MPI_Barrier(MPI_COMM_WORLD); + total_my_bcast_time -= MPI_Wtime(); + my_bcast(data, num_elements, MPI_INT, 0, MPI_COMM_WORLD); + // Synchronize again before obtaining final time + MPI_Barrier(MPI_COMM_WORLD); + total_my_bcast_time += MPI_Wtime(); + // Time MPI_Bcast + MPI_Barrier(MPI_COMM_WORLD); + total_mpi_bcast_time -= MPI_Wtime(); + MPI_Bcast(data, num_elements, MPI_INT, 0, MPI_COMM_WORLD); + MPI_Barrier(MPI_COMM_WORLD); + total_mpi_bcast_time += MPI_Wtime(); + } + // Print off timing information + if (world_rank == 0) { + printf("Data size = %d, Trials = %d\n", num_elements * (int)sizeof(int), + num_trials); + printf("Avg my_bcast time = %lf\n", total_my_bcast_time / num_trials); + printf("Avg MPI_Bcast time = %lf\n", total_mpi_bcast_time / num_trials); + } + MPI_Finalize(); +} diff --git a/test/c b/test/c new file mode 100644 index 0000000000000000000000000000000000000000..4f07d5df20a431df6420062973c3b1c1647f3542 Binary files /dev/null and b/test/c differ diff --git a/test/c.c b/test/c.c new file mode 100644 index 0000000000000000000000000000000000000000..3d6abc97d6a6f09ddcd842ff35e92ff731bd01a6 --- /dev/null +++ b/test/c.c @@ -0,0 +1,108 @@ +#include "mpi.h" +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <limits.h> + +int N = 5000; + +int getmin_index(short **graph, bool pickedVertices[N], int sourceVertex) { + int minDistance = CHAR_MAX; + int min_index = -1; + + for (int j = 0; j < N; j++) { + if (!pickedVertices[j] && graph[sourceVertex][j] <= minDistance) { + minDistance = graph[sourceVertex][j]; + min_index = j; + } + } + return min_index; +} + +void print(short **graph){ + printf("Matrix: \n"); + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + printf("%d ", graph[i][j]); + } + printf("\n"); + } +} + +void dijkstra(short **graph, int sourceVertex) { + + // Distance from single source to all of the nodes + bool pickedVertices[N]; + + for (int vertex = 0; vertex < N; vertex++) { + pickedVertices[vertex] = false; + } + + for (int i = 0; i < N - 1; i++) { + // Get minimum distance + int min_index = getmin_index(graph, pickedVertices, sourceVertex); + + // Mark the vertice as picked + pickedVertices[min_index] = true; + + // Update distance value + for (int vertex = 0; vertex < N; vertex++) { + if ((!pickedVertices[vertex]) && + (graph[min_index][vertex]) && + (graph[sourceVertex][min_index] != INT_MAX) && + (graph[sourceVertex][min_index] + graph[min_index][vertex] < graph[sourceVertex][vertex])) { + + graph[sourceVertex][vertex] = graph[sourceVertex][min_index] + graph[min_index][vertex]; + } + } + } + return; +} + +int main(int argc, char *argv[]) { + + short** graph; + graph = (short**) malloc(sizeof(short*) * 5000); + for (int i = 0; i < 5000; ++i) + { + graph[i] = (short*) malloc(sizeof(short) * 5000); + } + + + // Get matrix size from argument vector in , convert to int + printf("pass\n"); + srand(13517115); + // Fill the matrix with rand() function + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + // Mod by 100 so the result won't be too big. + graph[i][j] = 1; + } + } + /*for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (!(i == j || graph[i][j])){ + graph[i][j] = CHAR_MAX; + } + } + } + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (i == j){ + graph[i][j] = 0; + } + } + }*/ + + /*for (int i = 0; i < N; ++i) + { + dijkstra(graph, i); + printf("%d\n", i); + }*/ + print(graph); + for (int i = 0; i < 5000; ++i) + { + free(graph[i]); + } + free(graph); +} \ No newline at end of file diff --git a/test/comm.c b/test/comm.c new file mode 100644 index 0000000000000000000000000000000000000000..30820d4baa1af32e775517c28e7eb467755c41dd --- /dev/null +++ b/test/comm.c @@ -0,0 +1,31 @@ +// Copyright 2015 www.mpitutorial.com +#include <stdlib.h> +#include <stdio.h> +#include <mpi.h> +int main(int argc, char **argv) { + MPI_Init(NULL, NULL); + int world_rank, world_size; + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + MPI_Group world_group; + MPI_Comm_group(MPI_COMM_WORLD, &world_group); + int n = 7; + const int ranks[7] = {1, 2, 3, 5, 7, 11, 13}; + MPI_Group prime_group; + MPI_Group_incl(world_group, 7, ranks, &prime_group); + MPI_Comm prime_comm; + MPI_Comm_create_group(MPI_COMM_WORLD, prime_group, 0, &prime_comm); + int prime_rank = -1, prime_size = -1; + if (MPI_COMM_NULL != prime_comm) { +MPI_Comm_rank(prime_comm, &prime_rank); +MPI_Comm_size(prime_comm, &prime_size); + } + printf("WORLD RANK/SIZE: %d/%d --- PRIME RANK/SIZE: %d/%d\n", world_rank, +world_size, prime_rank, prime_size); + MPI_Group_free(&world_group); + MPI_Group_free(&prime_group); + if (MPI_COMM_NULL != prime_comm) { +MPI_Comm_free(&prime_comm); + } + MPI_Finalize(); +} diff --git a/test/reduce.c b/test/reduce.c new file mode 100644 index 0000000000000000000000000000000000000000..3e346dca22b4e00a5a5e533845625614db88f459 --- /dev/null +++ b/test/reduce.c @@ -0,0 +1,47 @@ +// Copyright 2013 www.mpitutorial.com +#include <stdio.h> +#include <stdlib.h> +#include <mpi.h> +#include <assert.h> +float *create_rand_nums(int num_elements) { + float *rand_nums = (float *)malloc(sizeof(float) * num_elements); + assert(rand_nums != NULL); + int i; + for (i = 0; i < num_elements; i++) { +rand_nums[i] = (rand() / (float)RAND_MAX); + } + return rand_nums; +} +int main(int argc, char** argv) { + if (argc != 2) { +fprintf(stderr, "Usage: avg num_elements_per_proc\n"); +exit(1); + } + int num_elements_per_proc = atoi(argv[1]); + MPI_Init(NULL, NULL); + int world_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); + int world_size; + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + srand(time(NULL)*world_rank); + float *rand_nums = NULL; + rand_nums = create_rand_nums(num_elements_per_proc); + float local_sum = 0; + int i; + for (i = 0; i < num_elements_per_proc; i++) { +local_sum += rand_nums[i]; + } + printf("Local sum for process %d - %f, avg = %f\n", world_rank, local_sum, +local_sum / num_elements_per_proc); + float global_sum; + MPI_Reduce(&local_sum, &global_sum, 1, MPI_FLOAT, MPI_SUM, 0, +MPI_COMM_WORLD); + if (world_rank == 0) { +printf("Total sum = %f, avg = %f\n", global_sum, global_sum / +(world_size * num_elements_per_proc)); + } + // Clean up + free(rand_nums); + MPI_Barrier(MPI_COMM_WORLD); + MPI_Finalize(); +} diff --git a/test/sg.c b/test/sg.c new file mode 100644 index 0000000000000000000000000000000000000000..b86351fc453e2b96c3a8d1b613f52420430b3e33 --- /dev/null +++ b/test/sg.c @@ -0,0 +1,65 @@ +// Copyright 2012 www.mpitutorial.com +// Program yang menghitung rata-rata dari array secara paralel menggunakan Scatter dan Gather. +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <mpi.h> +#include <assert.h> +float *create_rand_nums(int num_elements) { + float *rand_nums = (float *)malloc(sizeof(float) * num_elements); + assert(rand_nums != NULL); + int i; + for (i = 0; i < num_elements; i++) { +rand_nums[i] = (rand() / (float)RAND_MAX); + } + return rand_nums; +} +float compute_avg(float *array, int num_elements) { + float sum = 0.f; + int i; + for (i = 0; i < num_elements; i++) { +sum += array[i]; + } + return sum / num_elements; +} +int main(int argc, char** argv) { + if (argc != 2) { +fprintf(stderr, "Usage: avg num_elements_per_proc\n"); +exit(1); + } + int num_elements_per_proc = atoi(argv[1]); + srand(time(NULL)); + MPI_Init(NULL, NULL); + int world_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); + int world_size; + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + float *rand_nums = NULL; + if (world_rank == 0) { +rand_nums = create_rand_nums(num_elements_per_proc * world_size); + } + float *sub_rand_nums = (float *)malloc(sizeof(float) * +num_elements_per_proc); + assert(sub_rand_nums != NULL); + MPI_Scatter(rand_nums, num_elements_per_proc, MPI_FLOAT, sub_rand_nums, +num_elements_per_proc, MPI_FLOAT, 0, MPI_COMM_WORLD); + float sub_avg = compute_avg(sub_rand_nums, num_elements_per_proc); + float *sub_avgs = NULL; + if (world_rank == 0) { +sub_avgs = (float *)malloc(sizeof(float) * world_size); +assert(sub_avgs != NULL); + } + MPI_Gather(&sub_avg, 1, MPI_FLOAT, sub_avgs, 1, MPI_FLOAT, 0, +MPI_COMM_WORLD); + if (world_rank == 0) { +float avg = compute_avg(sub_avgs, world_size); +printf("Avg of all elements is %f\n", avg); + } + if (world_rank == 0) { +free(rand_nums); +free(sub_avgs); + } + free(sub_rand_nums); + MPI_Barrier(MPI_COMM_WORLD); + MPI_Finalize(); +}