diff options
Diffstat (limited to 'nerv/lib/matrix/generic/matrix.c')
-rw-r--r-- | nerv/lib/matrix/generic/matrix.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nerv/lib/matrix/generic/matrix.c b/nerv/lib/matrix/generic/matrix.c index 998d107..004d9aa 100644 --- a/nerv/lib/matrix/generic/matrix.c +++ b/nerv/lib/matrix/generic/matrix.c @@ -9,6 +9,8 @@ void nerv_matrix_(data_free)(Matrix *self, Status *status) { { /* free matrix data */ MATRIX_DATA_FREE(MATRIX_ELEM_PTR_BASE(self), status); + curandDestroyGenerator(*(self->curand_gen)); + free(self->curand_gen); free(self->data_ref); free(self); } @@ -38,6 +40,11 @@ Matrix *nerv_matrix_(create)(long nrow, long ncol, Status *status) { } self->data_ref = (long *)malloc(sizeof(long)); *self->data_ref = 0; + + self->curand_gen = (curandGenerator_t*)malloc(sizeof(curandGenerator_t)); + curandCreateGenerator(self->curand_gen, CURAND_RNG_PSEUDO_DEFAULT); + curandSetPseudoRandomGeneratorSeed(*(self->curand_gen), time(NULL)); + self->offset = 0; nerv_matrix_(data_retain)(self); NERV_SET_STATUS(status, NERV_NORMAL, 0); @@ -57,6 +64,7 @@ Matrix *nerv_matrix_(getrow)(Matrix *self, int row) { prow->nmax = prow->ncol; prow->data = self->data; prow->data_ref = self->data_ref; + prow->curand_gen = self->curand_gen; prow->offset = row * self->stride; nerv_matrix_(data_retain)(prow); return prow; |