events.h 1.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/**
 * \file imperative/src/impl/interpreter/events.h
 * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
 *
 * Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
 *
 * 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 "./commands.h"
#include "./tensor_info.h"

namespace mgb::imperative::interpreter::intl {

19 20
#define DEF_EVENT(X, ...) struct X##Event __VA_ARGS__;
#define DEF_DUR_EVENT(X, ...) struct X##Event __VA_ARGS__; struct X##FinishEvent __VA_ARGS__;
21

22 23 24
DEF_EVENT(Command, {
    IdentifiedCommand icmd;
});
25

26 27 28 29
DEF_EVENT(CommandEnqueue, :CommandEvent);
DEF_EVENT(CommandExecute, :CommandEvent);
DEF_EVENT(CommandFinish, :CommandEvent);
DEF_DUR_EVENT(OpExecute, {
30 31 32 33
    uint64_t id;
    std::shared_ptr<OpDef> op;
    SmallVector<uint64_t> inputs;
    SmallVector<uint64_t> outputs;
34 35 36 37 38 39 40 41
});
DEF_DUR_EVENT(KernelExecute, {
    uint64_t id;
    std::shared_ptr<OpDef> op;
    SmallVector<uint64_t> inputs;
    SmallVector<uint64_t> outputs;
});
DEF_EVENT(TensorDeclare, {
42
    uint64_t tensor_id;
43 44
});
DEF_EVENT(TensorProduce, {
45 46 47
    uint64_t tensor_id;
    TensorLayout layout;
    CompNode device;
48 49
});
DEF_EVENT(TensorErase, {
50
    uint64_t tensor_id;
51 52
});
DEF_EVENT(TensorGetProp, {
53 54 55
    uint64_t tensor_id;
    TensorInfo::Prop prop;
    std::string prop_desc;
56 57 58 59 60 61 62 63 64 65 66 67 68
});
DEF_DUR_EVENT(TensorWaitProp, {
    uint64_t tensor_id;
    TensorInfo::Prop prop;
    std::string prop_desc;
});
DEF_EVENT(TensorNotifyProp, {
    uint64_t tensor_id;
    TensorInfo::Prop prop;
    std::string prop_desc;
});
DEF_DUR_EVENT(Sync, {});
DEF_DUR_EVENT(Scope, {
69
    std::string name;
70 71 72 73
});
DEF_DUR_EVENT(DeviceScope, {
    std::string name;
});
74 75

}