utils.mlu.h 1.2 KB
Newer Older
1 2 3 4
/**
 * \file dnn/src/cambricon/utils.mlu.h
 * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
 *
5
 * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 */
#pragma once

#include "src/common/utils.cuh"

#include <stdint.h>

#include <cnrt.h>

#define cnrt_check(_x)                                            \
    do {                                                          \
        cnrtRet_t _ret = (_x);                                    \
        if (_ret != CNRT_RET_SUCCESS) {                           \
            ::megdnn::cambricon::__throw_cnrt_error__(_ret, #_x); \
        }                                                         \
    } while (0)

#define after_kernel_launch()         \
    do {                              \
        cnrt_check(cnrtGetLastErr()); \
    } while (0)

namespace megdnn {
namespace cambricon {

//! Error handling funcions
MEGDNN_NORETURN void __throw_cnrt_error__(cnrtRet_t err, const char* msg);

}  // namespace cambricon
}  // namespace megdnn

// vim: syntax=cpp.doxygen