diff options
author | Determinant <[email protected]> | 2015-06-05 10:58:57 +0800 |
---|---|---|
committer | Determinant <[email protected]> | 2015-06-05 10:58:57 +0800 |
commit | df737041e4a9f3f55978cc74db9a9cea27fa9fa0 (patch) | |
tree | d656820be286550bc548f7c5ed4b1dcfecf3691c /matrix/cumatrix.c | |
parent | ea6f2990f99dd9ded6a0e74d75a3ec84900a2518 (diff) |
add profiling; add ce accurarcy; several other changes
Diffstat (limited to 'matrix/cumatrix.c')
-rw-r--r-- | matrix/cumatrix.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/matrix/cumatrix.c b/matrix/cumatrix.c index 51a3681..4ebc5ff 100644 --- a/matrix/cumatrix.c +++ b/matrix/cumatrix.c @@ -1,4 +1,38 @@ #define NERV_GENERIC_CUMATRIX +#include "../common.h" +#include "cuda_helper.h" +static cublasHandle_t cublas_handle; +static HashMap *profile; + +int print_profile(lua_State *L) { + size_t i; + fprintf(stderr, "*** [nerv cumatrix profile] **\n"); + for (i = 0; i < profile->size; i++) + { + HashNode *ptr; + for (ptr = profile->bucket[i]; ptr; ptr = ptr->next) + { + fprintf(stderr, "%s:\t%.6f\n", ptr->key, *(float *)ptr->val); + } + } + return 0; +} + +int clear_profile(lua_State *L) { + hashmap_clear(profile); + return 0; +} + +void accu_profile(const char *name, float delta) { + float *val = hashmap_getval(profile, name); + if (!val) + { + val = malloc(sizeof(float)); + *val = 0; + hashmap_setval(profile, name, val); + } + *val += delta; +} #define MATRIX_USE_FLOAT #define cuda_matrix_(NAME) cuda_matrix_float_##NAME |