This file contains 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
(defproject myproj "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:main ^:skip-aot myproj.core | |
:dependencies [[org.clojure/clojure "1.6.0"]]) |
This file contains 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 <cstdlib> | |
#include <ctime> | |
#include <cassert> | |
#include <sys/time.h> | |
#include <unistd.h> | |
#include <set> | |
#include <vector> | |
#include <algorithm> |
This file contains 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
/* | |
* 計算機システム MPIサンプル [1] | |
* MPIを使って起動・終了するだけのプログラム(MPIのインストール/動作の確認) | |
*/ | |
#include <mpi.h> | |
int main(int argc, char **argv) { | |
MPI_Init(&argc, &argv); |
This file contains 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
/* | |
* 計算機システム MPIサンプル [2] | |
* MPIが起動されているプロセス数と、各プロセスが自分のプロセスIDを表示する | |
*/ | |
#include <stdio.h> | |
#include <mpi.h> | |
int main(int argc, char **argv) { | |
int rank; /* 自分自身のプロセスID */ |
This file contains 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
/* | |
* 計算機システム MPIサンプル [3] | |
* MPI_Send と MPI_Recv を使ったサンプル | |
* 各プロセスが、rank 0 へとデータを送る(データ=自分のプロセスIDを二乗した値の整数1個) | |
*/ | |
#include <stdio.h> | |
#include <assert.h> | |
#include <mpi.h> |
This file contains 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
/* | |
* 計算機システム MPIサンプル [4] | |
* rank 0 のプロセスから、0以外のプロセスへ、配列を送信し、各プロセスは、データの各要素に自分のrankをかけ算し、 | |
* その配列をrank 0へ送り返す | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <mpi.h> |
This file contains 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
/* | |
* 計算機システム MPIサンプル [5] | |
* サンプル[4]の処理は、通信と受信を一発で行うAPIが用意されている | |
* ここでは MPI_Scatter と MPI_Gather の例を示す。 | |
* 実行結果は、サンプル[4]と全く同じになる. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> |
This file contains 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
/* | |
* 計算機システム MPIサンプル [6] | |
* MPIのプロセスが実際にどのホストで実行されているかを調べる | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <mpi.h> |
This file contains 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
/* | |
* 計算機システム MPIサンプル [7] | |
* MPI_Barrierとgettimeofdayの時間計測の例 | |
* 各ノードで独立に整数のソートを行って、MPI_Barrier() で同期を行って時間を計測する | |
* (結果的に、「一番時間がかかったプロセスの時間 + 同期コスト」の時間を計測することになる) | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> |
This file contains 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
void func1(int n, double *mat, double *sum) { | |
int col, row; | |
for (col = 0; col < n; col++) { | |
sum[col] = 0; | |
} | |
for (col = 0; col < n; col++) { | |
for (row = 0; row < n; row++) { | |
sum[col] += mat[n * row + col]; | |
} |