Browse Source

Minor fixes

master
Apostolos Fanakis 7 years ago
parent
commit
8d27890715
  1. 4
      mean_shift_cuda/Makefile
  2. 9
      mean_shift_cuda/meanshift.c
  3. 18
      mean_shift_cuda/meanshift_declarations.c
  4. 2
      mean_shift_cuda/meanshift_declarations.h

4
mean_shift_cuda/Makefile

@ -3,9 +3,9 @@ SHELL := /bin/bash
# ============================================ # ============================================
# COMMANDS # COMMANDS
CC = nvcc CC = /usr/local/cuda/bin/nvcc -ccbin gcc
RM = rm -f RM = rm -f
CFLAGS=-lm -O3 -Wall -I. CFLAGS=-lm -O3 -I.
OBJ=meanshift.o meanshift_declarations.o OBJ=meanshift.o meanshift_declarations.o
DEPS=meanshift_declarations.h DEPS=meanshift_declarations.h

9
mean_shift_cuda/meanshift.c

@ -11,15 +11,12 @@
int NUMBER_OF_POINTS = 600; int NUMBER_OF_POINTS = 600;
int DIMENSIONS = 2; int DIMENSIONS = 2;
char* POINTS_FILENAME = "data/X.bin"; char* POINTS_FILENAME = "../data/X.bin";
char* LABELS_FILENAME = "data/L.bin"; char* LABELS_FILENAME = "../data/L.bin";
struct timeval startwtime, endwtime; struct timeval startwtime, endwtime;
double seq_time; double seq_time;
int meanshift(double **original_points, double ***shifted_points, int h
, parameters *opt, int iteration);
__device__ double norm(double **matrix, int rows, int cols){ __device__ double norm(double **matrix, int rows, int cols){
double sum=0, temp_mul=0; double sum=0, temp_mul=0;
@ -92,8 +89,6 @@ int main(int argc, char **argv){
//save_matrix(shifted_points, iterations); //save_matrix(shifted_points, iterations);
} }
int meanshift(double **original_points, double ***shifted_points, int h int meanshift(double **original_points, double ***shifted_points, int h
, parameters *opt, int iteration){ , parameters *opt, int iteration){

18
mean_shift_cuda/meanshift_declarations.c

@ -24,20 +24,6 @@ void get_args(int argc, char **argv, int *h){
LABELS_FILENAME = argv[5]; LABELS_FILENAME = argv[5];
} }
// TODO check why there's is a difference in the norm calculate in matlab
double norm(double **matrix, int rows, int cols){
double sum=0, temp_mul=0;
for (int i=0; i<rows; i++) {
for (int j=0; j<cols; j++) {
temp_mul = matrix[i][j] * matrix[i][j];
sum = sum + temp_mul;
}
}
double norm = sqrt(sum);
return norm;
}
double **alloc_2d_double(int rows, int cols) { double **alloc_2d_double(int rows, int cols) {
double *data = (double *) malloc(rows*cols*sizeof(double)); double *data = (double *) malloc(rows*cols*sizeof(double));
double **array = (double **) malloc(rows*sizeof(double*)); double **array = (double **) malloc(rows*sizeof(double*));
@ -64,8 +50,8 @@ void print_matrix(double **array, int rows, int cols){
} }
void save_matrix(double **matrix, int iteration){ void save_matrix(double **matrix, int iteration){
char filename[18]; char filename[50];
snprintf(filename, sizeof(filename), "%s%d", "output/output_", iteration); snprintf(filename, sizeof(filename), "%s%d", "../output/output_", iteration);
FILE *file; FILE *file;
file = fopen(filename, "w"); file = fopen(filename, "w");
for (int rows=0; rows<NUMBER_OF_POINTS; ++rows){ for (int rows=0; rows<NUMBER_OF_POINTS; ++rows){

2
mean_shift_cuda/meanshift_declarations.h

@ -25,7 +25,7 @@ int meanshift(double **original_points, double ***shifted_points, int h
, parameters *opt, int iteration); , parameters *opt, int iteration);
//Function norm returns the second norm of matrix of dimensions rowsXcols. //Function norm returns the second norm of matrix of dimensions rowsXcols.
double norm(double **matrix, int rows, int cols); //double norm(double **matrix, int rows, int cols);
//Function alloc_2d_double allocates rows*cols bytes of continuous memory. //Function alloc_2d_double allocates rows*cols bytes of continuous memory.
double **alloc_2d_double(int rows, int cols); double **alloc_2d_double(int rows, int cols);

Loading…
Cancel
Save