Line data Source code
1 : /*
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : /*!
12 : * \file sk_scope_launch.cpp
13 : * \brief
14 : */
15 :
16 : #include "sk_scope_launch.h"
17 :
18 : #include <cstring>
19 :
20 : #include "securec.h"
21 : #include "sk_common.h"
22 : #include "sk_log.h"
23 :
24 : namespace {
25 :
26 8 : bool IsScopeNameValid(const char *scopeName) {
27 : if (scopeName == nullptr) {
28 2 : return true;
29 : }
30 6 : return strlen(scopeName) <= MAX_SCOPE_NAME_LEN - 1;
31 : }
32 :
33 : } // namespace
34 :
35 : aclError LaunchScopeKernel(const char *scopeName, aclrtStream stream, bool isBegin) {
36 : (void)stream;
37 : (void)isBegin;
38 8 : if (!IsScopeNameValid(scopeName)) {
39 1 : SK_DLOGE("Scope name exceeds the maximum length: scopeNameLength=%zu, maxLength=%u", strlen(scopeName),
40 : MAX_SCOPE_NAME_LEN - 1);
41 1 : return ACL_ERROR_INVALID_PARAM;
42 : }
43 7 : return ACL_SUCCESS;
44 : }
|