Moved common defs from gpuMILibrary to gpuKnnLibrary.

In preparation for gpuCMILibrary.
This commit is contained in:
Pedro Martinez Mediano 2017-12-12 11:16:03 +00:00
parent f4ca442de4
commit b7dd2fca5f
4 changed files with 21 additions and 20 deletions

View File

@ -594,6 +594,21 @@ void device_reset(void) {
void gpuWarmUp(void) {
cudaSetDevice(0);
}
/**
* Make random permutation of perm[].
*
* @param perm preallocated and prefilled integer array to be shuffled
* @param n number of elements in perm
*/
void randperm(int perm[], int n) {
// Random permutation the order
for (int i = 0; i < n; i++) {
int j, t;
j = rand() % (n-i) + i;
t = perm[j]; perm[j] = perm[i]; perm[i] = t; // Swap i and j
}
}
#ifdef __cplusplus
}
#endif

View File

@ -4,6 +4,8 @@
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { JIDT_SUCCESS, JIDT_ERROR } jidt_error_t;
int allocateDeviceMemory(int signalLength, int kth, int dimx, int dimy,
float **source, float **dest, float **distances, int **indexes,
float **radii, int **nx, int **ny, float **digammas, float *pointset);
@ -53,6 +55,8 @@ int d_cudaSumDigammas(float *sumDigammas, int *d_nx, int *d_ny,
void device_reset(void);
void gpuWarmUp(void);
void randperm(int perm[], int n);
#ifdef __cplusplus
}
#endif

View File

@ -8,22 +8,6 @@
#include "ctimer.h"
/**
* Make random permutation of perm[].
*
* @param perm preallocated and prefilled integer array to be shuffled
* @param n number of elements in perm
*/
void randperm(int perm[], int n) {
// Random permutation the order
for (int i = 0; i < n; i++) {
int j, t;
j = rand() % (n-i) + i;
t = perm[j]; perm[j] = perm[i]; perm[i] = t; // Swap i and j
}
}
jidt_error_t MIKraskov_C(int N, float *source, int dimx, float *dest, int dimy,
int k, int thelier, int nb_surrogates, int returnLocals, int useMaxNorm,
int isAlgorithm1, float *result) {

View File

@ -1,13 +1,13 @@
#ifndef GPUMILIBRARY_H
#define GPUMILIBRARY_H
#include "gpuKnnLibrary.h"
#define FREE(x) { if (x) free(x); x = NULL; }
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { JIDT_SUCCESS, JIDT_ERROR } jidt_error_t;
jidt_error_t MIKraskovWithReorderings(int N, float *source, int dimx, float *dest, int dimy,
int k, int thelier, int nb_surrogates, int returnLocals, int useMaxNorm,
int isAlgorithm1, float *result, int reorderingsGiven, int **reorderings);
@ -20,8 +20,6 @@ jidt_error_t MIKraskovByPointsetChunks(int N, float *source, int dimx,
float *dest, int dimy, int k, int thelier, int nb_surrogates,
int returnLocals, int useMaxNorm, int isAlgorithm1, float *result,
float *pointset);
void randperm(int perm[], int n);
#ifdef __cplusplus
}
#endif