-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
EC2 Default User
committed
Apr 16, 2017
1 parent
1f2aa44
commit 12d5745
Showing
4 changed files
with
31 additions
and
25 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
gcc -O2 -std=c99 -lnetcdf -fopenmp -lpthread Kmean_omp.c -o Kmean_omp.out | ||
gcc -O2 -std=c99 -lnetcdf -fopenmp -lpthread ../shared/make_2D_array.c Kmean_omp.c -o Kmean_omp.out | ||
|
||
#For debugging with gdb | ||
#gcc -g -O0 -std=c99 -lnetcdf Kmean_seq.c -o Kmean_seq.out |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "./make_2D_array.h" | ||
#include <stdlib.h> //for malloc | ||
|
||
/* For dynamically allocating 2D array in pure-C environment. | ||
Unlke in HW2, the array here is contagious! | ||
See: | ||
http:https://stackoverflow.com/questions/33794657/how-to-pass-a-2d-array-to-a-function-in-c-when-the-array-is-formatted-like-this | ||
http:https://stackoverflow.com/questions/5901476/sending-and-receiving-2d-array-over-mpi | ||
*/ | ||
float** Make2DFloatArray(int rows, int cols) { | ||
float *data = (float *)malloc(rows*cols*sizeof(float)); | ||
float **array= (float **)malloc(rows*sizeof(float*)); | ||
for (int i=0; i<rows; i++) | ||
array[i] = &(data[cols*i]); | ||
|
||
return array; | ||
} | ||
int** Make2DIntArray(int rows, int cols) { | ||
int *data = (int *)malloc(rows*cols*sizeof(int)); | ||
int **array= (int **)malloc(rows*sizeof(int*)); | ||
for (int i=0; i<rows; i++) | ||
array[i] = &(data[cols*i]); | ||
|
||
return array; | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
float** Make2DFloatArray(int rows, int cols); | ||
int** Make2DIntArray(int rows, int cols); |