aboutsummaryrefslogtreecommitdiff
path: root/nerv/lib/matrix
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2016-02-24 17:26:45 +0800
committerDeterminant <ted.sybil@gmail.com>2016-02-24 17:26:45 +0800
commit550680eacd00555817df19d2b59a20a92df77c42 (patch)
treebe9e39e2115fa95e99e32791898ba5593ca3b23f /nerv/lib/matrix
parente91fc2ddaa74dd2c46ce93c9e92020d66c037c8e (diff)
clean up code
Diffstat (limited to 'nerv/lib/matrix')
-rw-r--r--nerv/lib/matrix/cuda_helper.h15
-rw-r--r--nerv/lib/matrix/cumatrix.c5
-rw-r--r--nerv/lib/matrix/generic/mmatrix.c2
-rw-r--r--nerv/lib/matrix/mmatrix.c17
4 files changed, 13 insertions, 26 deletions
diff --git a/nerv/lib/matrix/cuda_helper.h b/nerv/lib/matrix/cuda_helper.h
index 5c75e38..2d18486 100644
--- a/nerv/lib/matrix/cuda_helper.h
+++ b/nerv/lib/matrix/cuda_helper.h
@@ -76,21 +76,6 @@
cudaDeviceSynchronize(); \
} while (0)
-#define CHECK_SAME_DIMENSION(a, b, status) \
- do { \
- if (!(a->nrow == b->nrow && a->ncol == b->ncol)) \
- NERV_EXIT_STATUS(status, MAT_MISMATCH_DIM, 0); \
- } while (0)
-
-#define CHECK_SAME_DIMENSION_RET(a, b, status) \
- do { \
- if (!(a->nrow == b->nrow && a->ncol == b->ncol)) \
- { \
- NERV_SET_STATUS(status, MAT_MISMATCH_DIM, 0); \
- return 0; \
- } \
- } while (0)
-
static const char *cublasGetErrorString(cublasStatus_t err) {
switch (err)
{
diff --git a/nerv/lib/matrix/cumatrix.c b/nerv/lib/matrix/cumatrix.c
index 2fbe7d8..ff2ea22 100644
--- a/nerv/lib/matrix/cumatrix.c
+++ b/nerv/lib/matrix/cumatrix.c
@@ -1,9 +1,10 @@
#define NERV_GENERIC_CUMATRIX
#define MATRIX_CONTEXT CuContext
-#include "cumatrix.h"
-#include "cuda_helper.h"
#include <string.h>
#include <time.h>
+#include "../common.h"
+#include "cumatrix.h"
+#include "cuda_helper.h"
void nerv_cuda_context_print_profile(CuContext *context) {
HashMap *profile = context->profile;
diff --git a/nerv/lib/matrix/generic/mmatrix.c b/nerv/lib/matrix/generic/mmatrix.c
index ad334e3..485d778 100644
--- a/nerv/lib/matrix/generic/mmatrix.c
+++ b/nerv/lib/matrix/generic/mmatrix.c
@@ -7,10 +7,10 @@
host_matrix_(alloc)(dptr, stride, width, height, \
context, status)
#define NERV_GENERIC_MATRIX
-#include "../cuda_helper.h"
#include "../../common.h"
#include "../../io/chunk_file.h"
#include <string.h>
+#include <math.h>
#include <cblas.h>
#include <float.h>
diff --git a/nerv/lib/matrix/mmatrix.c b/nerv/lib/matrix/mmatrix.c
index f1cbc75..e40b160 100644
--- a/nerv/lib/matrix/mmatrix.c
+++ b/nerv/lib/matrix/mmatrix.c
@@ -1,17 +1,10 @@
#define NERV_GENERIC_MMATRIX
#define MATRIX_CONTEXT MContext
+#include <string.h>
#include <stdlib.h>
#include "../common.h"
#include "mmatrix.h"
-#define MATRIX_USE_FLOAT
-#define host_matrix_(NAME) host_matrix_float_##NAME
-#define nerv_matrix_(NAME) nerv_matrix_host_float_##NAME
-#define NERV_CBLAS_(NAME) cblas_s##NAME
-#include "generic/matrix.h"
-#include "generic/elem_type.h"
-#include "generic/mmatrix.c"
-
void nerv_host_context_print_profile(MContext *context) {
HashMap *profile = context->profile;
size_t i;
@@ -43,6 +36,14 @@ void nerv_host_context_destroy(MContext *context, Status *status) {
NERV_SET_STATUS(status, NERV_NORMAL, 0);
}
+#define MATRIX_USE_FLOAT
+#define host_matrix_(NAME) host_matrix_float_##NAME
+#define nerv_matrix_(NAME) nerv_matrix_host_float_##NAME
+#define NERV_CBLAS_(NAME) cblas_s##NAME
+#include "generic/matrix.h"
+#include "generic/elem_type.h"
+#include "generic/mmatrix.c"
+
Matrix *nerv_matrix_(perm_gen)(int ncol, MContext *context, Status *status) {
int i;
Matrix *self = nerv_matrix_(create)(1, ncol, context, status);