polish exit cleanup

This commit is contained in:
Dun Liang 2021-08-31 11:41:41 +08:00
parent 7349284663
commit aa749dd0e0
5 changed files with 8 additions and 4 deletions

View File

@ -9,7 +9,7 @@
# file 'LICENSE.txt', which is part of this source code package.
# ***************************************************************
__version__ = '1.2.3.94'
__version__ = '1.2.3.95'
from jittor_utils import lock
with lock.lock_scope():
ori_int = int

View File

@ -20,6 +20,8 @@ namespace jittor {
CublasMatmulOp::CublasMatmulOp(Var* a, Var* b, bool trans_a, bool trans_b)
: a(a), b(b), trans_a(trans_a), trans_b(trans_b) {
flags.set(NodeFlags::_cuda, 1);
flags.set(NodeFlags::_cpu, 0);
// TODO: support int8 * int8
ASSERT(a->dtype().is_float() && b->dtype().is_float()) << "type of two inputs should be the same";
// TODO: support diffrent input type
@ -51,7 +53,6 @@ void CublasMatmulOp::jit_prepare(JK& jk) {
}
#else // JIT
#ifdef JIT_cpu
#pragma clang diagnostic ignored "-Wtautological-compare"
void CublasMatmulOp::jit_run() {
cublasHandle_t& handle_ = cublas_handle;
@ -78,7 +79,6 @@ void CublasMatmulOp::jit_run() {
a->ptr<T>(), '@Trans_a' == 'N' ? m : n, &beta,
c->ptr<T>(), k));
}
#endif
#endif // JIT
} // jittor

View File

@ -19,11 +19,12 @@ struct cublas_initer {
inline cublas_initer() {
if (!get_device_count()) return;
checkCudaErrors(cublasCreate(&cublas_handle));
LOGv << "cublasCreate finished";
LOGv << "cublasCreate finished" << (void*)cublas_handle;
}
inline ~cublas_initer() {
if (!get_device_count()) return;
LOGv << "cublasDestroy:" << (void*)cublas_handle;
checkCudaErrors(cublasDestroy(cublas_handle));
LOGv << "cublasDestroy finished";
}

View File

@ -29,8 +29,10 @@ int current_seed;
// fron fetch_op.cc
extern list<VarPtr> fetcher;
extern list<VarPtr> fetcher_to_free;
extern bool exited;
void cleanup() {
exited = true;
fetcher_to_free.clear();
fetcher.clear();
}

View File

@ -235,6 +235,7 @@ void segfault_sigaction(int signal, siginfo_t *si, void *arg) {
exited = true;
do_exit();
}
if (exited) do_exit();
std::cerr << "Caught segfault at address " << si->si_addr << ", "
<< "thread_name: '" << thread_name << "', flush log..." << std::endl;
std::cerr.flush();