diff options
author | Determinant <ted.sybil@gmail.com> | 2016-02-24 16:58:32 +0800 |
---|---|---|
committer | Determinant <ted.sybil@gmail.com> | 2016-02-24 16:58:32 +0800 |
commit | e91fc2ddaa74dd2c46ce93c9e92020d66c037c8e (patch) | |
tree | 94165c3c81b1af93e9b77b408372c0d9ff23dd6b /nerv/matrix/matrix.h | |
parent | 9642bd16922b288c81dee25f17373466ae6888c4 (diff) |
add CuContext/MContextwrapped-handles
Diffstat (limited to 'nerv/matrix/matrix.h')
-rw-r--r-- | nerv/matrix/matrix.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nerv/matrix/matrix.h b/nerv/matrix/matrix.h new file mode 100644 index 0000000..788f596 --- /dev/null +++ b/nerv/matrix/matrix.h @@ -0,0 +1,24 @@ +#ifndef NERV_LUA_MATRIX_H +#define NERV_LUA_MATRIX_H +#include "../lib/luaT/luaT.h" +#define _MATRIX_GET_CONTEXT(L, p, tname, ctname) \ + do { \ + if (lua_gettop(L) < p) \ + { \ + luaT_pushmetatable(L, tname); \ + lua_getfield(L, -1, "_default_context"); \ + context = luaT_checkudata(L, -1, ctname); \ + lua_pop(L, 2); \ + } \ + else \ + { \ + context = luaT_checkudata(L, p, ctname); \ + } \ + } while (0) + +extern const char *nerv_cuda_context_tname; +extern const char *nerv_host_context_tname; +extern const char *nerv_matrix_host_tname; +#define MATRIX_GET_CONTEXT(L, p) _MATRIX_GET_CONTEXT(L, p, nerv_matrix_(tname), MATRIX_CONTEXT_TNAME) +#define MMATRIX_GET_CONTEXT(L, p) _MATRIX_GET_CONTEXT(L, p, nerv_matrix_host_tname, nerv_host_context_tname) +#endif |