xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/xla/service/gpu/target_constants.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2 
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 TENSORFLOW_COMPILER_XLA_SERVICE_GPU_TARGET_CONSTANTS_H_
17 #define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_TARGET_CONSTANTS_H_
18 
19 namespace xla {
20 namespace gpu {
21 
22 namespace nvptx {
23 // The triple that represents our target.
TargetTriple()24 inline const char* TargetTriple() {
25   static constexpr char kTargetTriple[] = "nvptx64-nvidia-cuda";
26   return kTargetTriple;
27 }
28 
29 // The data layout of the emitted module. Copied from computeDataLayout in
30 // NVPTXTargetMachine.cpp.
DataLayout()31 inline const char* DataLayout() {
32   static constexpr char kDataLayout[] =
33       "e-i64:64-i128:128-v16:16-v32:32-n16:32:64";
34   return kDataLayout;
35 }
36 }  // namespace nvptx
37 
38 namespace amdgpu {
39 
40 // The triple that represents our target on LLVM AMDGPU backend.
TargetTriple()41 inline const char* TargetTriple() {
42   static constexpr char kTargetTriple[] = "amdgcn-amd-amdhsa";
43   return kTargetTriple;
44 }
45 
46 // The data layout of the emitted module.
DataLayout()47 inline const char* DataLayout() {
48   static constexpr char kDataLayout[] =
49       "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32"
50       "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
51       "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5";
52   return kDataLayout;
53 }
54 
55 }  // namespace amdgpu
56 
57 }  // namespace gpu
58 }  // namespace xla
59 
60 #endif  // TENSORFLOW_COMPILER_XLA_SERVICE_GPU_TARGET_CONSTANTS_H_
61