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. 4
      mean_shift_cuda/meanshift_declarations.h

4
mean_shift_cuda/Makefile

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

9
mean_shift_cuda/meanshift.c

@ -11,15 +11,12 @@
int NUMBER_OF_POINTS = 600;
int DIMENSIONS = 2;
char* POINTS_FILENAME = "data/X.bin";
char* LABELS_FILENAME = "data/L.bin";
char* POINTS_FILENAME = "../data/X.bin";
char* LABELS_FILENAME = "../data/L.bin";
struct timeval startwtime, endwtime;
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){
double sum=0, temp_mul=0;
@ -92,8 +89,6 @@ int main(int argc, char **argv){
//save_matrix(shifted_points, iterations);
}
int meanshift(double **original_points, double ***shifted_points, int h
, 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];
}
// 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 *data = (double *) malloc(rows*cols*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){
char filename[18];
snprintf(filename, sizeof(filename), "%s%d", "output/output_", iteration);
char filename[50];
snprintf(filename, sizeof(filename), "%s%d", "../output/output_", iteration);
FILE *file;
file = fopen(filename, "w");
for (int rows=0; rows<NUMBER_OF_POINTS; ++rows){

4
mean_shift_cuda/meanshift_declarations.h

@ -22,10 +22,10 @@ void get_args(int argc, char **argv, int *h);
//options, h is the desirable deviation, iteration is this call's iteration
//number.
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.
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.
double **alloc_2d_double(int rows, int cols);

Loading…
Cancel
Save