Copyright (c) 2025-2025 Huawei Technologies Co., Ltd.
sysHAX-adapter is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
PURPOSE.
See the Mulan PSL v2 for more details.
Created: 2026-1-31
Desc: CPU inference cpu utils
*/
#ifndef CPU_UTILS_H
#define CPU_UTILS_H
#include <vector>
#include <string>
#include <omp.h>
typedef struct WorkDivider {
int num_threads;
int para;
int global_tid;
int tid;
int num_numas;
int threads_per_numa;
int my_numa;
int tid_in_numa;
} WorkDivider;
typedef struct SingleNumaWorkRange {
int begin_thread;
int end_thread;
int work_per_thread;
} SingleNumaWorkRange;
typedef struct MultiNumaWorkRange {
int begin_numa;
int work_per_numa;
int begin_thread;
int end_thread;
int work_per_thread;
} MultiNumaWorkRange;
void divide_work_single_numa(const WorkDivider *divider, int total_workitems, SingleNumaWorkRange *pstSingleRange);
void init_work_divider(WorkDivider* divider, int numas, int para = 1, bool exp = false);
void divide_all_work(const WorkDivider* divider, int total_workitems, SingleNumaWorkRange* pstSingleRange);
void divide_work_first_numa(const WorkDivider* divider, int total_workitems, SingleNumaWorkRange* pstSingleRange);
void divide_work_all_numas(const WorkDivider* divider, int total_workitems, MultiNumaWorkRange* pstNulRange);
#endif