1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FFRT_TYPES_HPP 17 #define FFRT_TYPES_HPP 18 #ifdef _MSC_VER 19 #define __attribute__(...) 20 #define FFRT_LIKELY(x) (__builtin_expect(!!(x), 1)) 21 #define FFRT_UNLIKELY(x) (__builtin_expect(!!(x), 0)) 22 #else 23 #define FFRT_LIKELY(x) (x) 24 #define FFRT_UNLIKELY(x) (x) 25 #endif 26 27 #ifdef MUTEX_PERF // Mutex Lock&Unlock Cycles Statistic 28 #include "sync/mutex_perf.h" 29 #endif 30 31 namespace ffrt { 32 #ifdef ASAN_MODE 33 constexpr bool USE_COROUTINE = false; 34 #else 35 constexpr bool USE_COROUTINE = true; 36 #endif 37 enum DT { 38 U8, 39 U16, 40 U32, 41 U64, 42 I8, 43 I16, 44 I32, 45 I64, 46 FP16, 47 FP32, 48 FP64, 49 }; 50 51 enum class DevType { 52 CPU, 53 DEVMAX, 54 }; 55 56 enum class TaskType { 57 ROOT, 58 DEFAULT, 59 }; 60 61 enum class DataStatus { 62 IDLE, // 默认状态 63 READY, // 当前版本被生产出来,标志着这个版本的所有消费者可以执行 64 CONSUMED, // 同时也是RELEASE,当前版本的所有消费者已经执行完成,标志着下一个版本的生产者可以执行 65 MERGED, // 嵌套场景下,标志一个子任务的version已经被父任务的version合并 66 }; 67 68 enum class NestType { 69 DEFAULT, // 不存在嵌套关系 70 PARENTOUT, // 同parent的输出嵌套 71 PARENTIN, // 同parent的输入嵌套 72 }; 73 74 enum class TaskStatus { 75 CONSTRUCTING, // 预留,暂不使用 76 SUBMITTING, // 预留,暂不使用 77 PENDING, // 默认状态 78 READY, // 可以被执行,可能由于上一个任务执行完而被依赖管理模块触发进入该状态(PEND->READY),也可能submit时被依赖管理模块触发进入该状态(PEND->READY) 79 EXECUTING, // 被调度器调度,正在执行,可能由调度模块触发进入该状态(READY->EXE),还可能由wait成功时被依赖管理模块触发进入该状态(BLOCK->EXE) 80 EXECUTING_NO_DEPENDENCE, // 执行过程中已经解依赖 81 BLOCKED, // 进入wait状态,wait时被依赖管理模块触发进入该状态(EXE->BLOCK) 82 FINISH, // 干完了(EXEC->FINISH) 83 RELEASED, // 预留,暂不使用 84 }; 85 86 enum class Denpence { 87 DEPENCE_INIT, 88 DATA_DEPENCE, 89 CALL_DEPENCE, 90 CONDITION_DEPENCE, 91 }; 92 93 enum class SpecTaskType { 94 EXIT_TASK, 95 SLEEP_TASK, 96 SPEC_TASK_MAX, 97 }; 98 99 enum SkipStatus { 100 SUBMITTED, 101 EXECUTED, 102 SKIPPED, 103 }; 104 105 #define FORCE_INLINE 106 } // namespace ffrt 107 #endif 108