Skip to content

Commit

Permalink
Hybrid MPI_OpenMPI finished
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaweiZhuang committed Apr 18, 2017
1 parent d34d49b commit 9ebeb57
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Parallel_Algorithm/MPI/Kmean_mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/* This is the name of the data file we will read. */
#define FILE_NAME "../test_data/Blobs_smp20000_fea30_cls8.nc"
#define TOL 0.0001
#define TOL 0.0001
#define MAX_ITER 100

int main() {
Expand Down Expand Up @@ -173,6 +173,9 @@ int main() {

// E-Step: assign points to the nearest cluster center
iStart3a = MPI_Wtime();
#pragma omp parallel for default(shared) schedule(static)\
private(i,j,k,k_best,dist,dist_min) \
reduction(+:dist_sum_new)
for (i = 0; i < N_samples; i++) {
k_best = 0;//assume cluster no.0 is the nearest
dist_min = distance(N_features, X[i], old_cluster_centers[k_best]);
Expand Down
17 changes: 17 additions & 0 deletions Parallel_Algorithm/MPI/test_hybrid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

np_list='1 2 4 8'
thread_list='1 2'

for np in $np_list
do
for thread in $thread_list
do
echo " "
echo =========================================
echo =========================================
echo testing with $np processes, $thread threads
export OMP_NUM_THREADS=$thread
mpiexec -np $np ./Kmean_mpi.out
done
done
1 change: 1 addition & 0 deletions Parallel_Algorithm/MPI/test_multiprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

np_list='1 2 4 8'

export OMP_NUM_THREADS=1 # make sure OpenMP disabled
for np in $np_list
do
echo " "
Expand Down

0 comments on commit 9ebeb57

Please sign in to comment.