aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/R600/AMDILDevice.h
blob: 97df98cafb2a877f06d0937145fa51d8bb7b2ffa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//===---- AMDILDevice.h - Define Device Data for AMDGPU -----*- C++ -*------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//==-----------------------------------------------------------------------===//
//
/// \file
/// \brief Interface for the subtarget data classes.
//
/// This file will define the interface that each generation needs to
/// implement in order to correctly answer queries on the capabilities of the
/// specific hardware.
//===----------------------------------------------------------------------===//
#ifndef AMDILDEVICEIMPL_H
#define AMDILDEVICEIMPL_H
#include "AMDIL.h"
#include "llvm/ADT/BitVector.h"

namespace llvm {
  class AMDGPUSubtarget;
  class MCStreamer;
//===----------------------------------------------------------------------===//
// Interface for data that is specific to a single device
//===----------------------------------------------------------------------===//
class AMDGPUDevice {
public:
  AMDGPUDevice(AMDGPUSubtarget *ST);
  virtual ~AMDGPUDevice();

  // Enum values for the various memory types.
  enum {
    RAW_UAV_ID   = 0,
    ARENA_UAV_ID = 1,
    LDS_ID       = 2,
    GDS_ID       = 3,
    SCRATCH_ID   = 4,
    CONSTANT_ID  = 5,
    GLOBAL_ID    = 6,
    MAX_IDS      = 7
  } IO_TYPE_IDS;

  /// \returns The max LDS size that the hardware supports.  Size is in
  /// bytes.
  virtual size_t getMaxLDSSize() const = 0;

  /// \returns The max GDS size that the hardware supports if the GDS is
  /// supported by the hardware.  Size is in bytes.
  virtual size_t getMaxGDSSize() const;

  /// \returns The max number of hardware constant address spaces that
  /// are supported by this device.
  virtual size_t getMaxNumCBs() const;

  /// \returns The max number of bytes a single hardware constant buffer
  /// can support.  Size is in bytes.
  virtual size_t getMaxCBSize() const;

  /// \returns The max number of bytes allowed by the hardware scratch
  /// buffer.  Size is in bytes.
  virtual size_t getMaxScratchSize() const;

  /// \brief Get the flag that corresponds to the device.
  virtual uint32_t getDeviceFlag() const;

  /// \returns The number of work-items that exist in a single hardware
  /// wavefront.
  virtual size_t getWavefrontSize() const = 0;

  /// \brief Get the generational name of this specific device.
  virtual uint32_t getGeneration() const = 0;

  /// \brief Get the stack alignment of this specific device.
  virtual uint32_t getStackAlignment() const;

  /// \brief Get the resource ID for this specific device.
  virtual uint32_t getResourceID(uint32_t DeviceID) const = 0;

  /// \brief Get the max number of UAV's for this device.
  virtual uint32_t getMaxNumUAVs() const = 0;


  // API utilizing more detailed capabilities of each family of
  // cards. If a capability is supported, then either usesHardware or
  // usesSoftware returned true.  If usesHardware returned true, then
  // usesSoftware must return false for the same capability.  Hardware
  // execution means that the feature is done natively by the hardware
  // and is not emulated by the softare.  Software execution means
  // that the feature could be done in the hardware, but there is
  // software that emulates it with possibly using the hardware for
  // support since the hardware does not fully comply with OpenCL
  // specs.

  bool isSupported(AMDGPUDeviceInfo::Caps Mode) const;
  bool usesHardware(AMDGPUDeviceInfo::Caps Mode) const;
  bool usesSoftware(AMDGPUDeviceInfo::Caps Mode) const;
  virtual std::string getDataLayout() const;
  static const unsigned int MAX_LDS_SIZE_700 = 16384;
  static const unsigned int MAX_LDS_SIZE_800 = 32768;
  static const unsigned int WavefrontSize = 64;
  static const unsigned int HalfWavefrontSize = 32;
  static const unsigned int QuarterWavefrontSize = 16;
protected:
  virtual void setCaps();
  BitVector mHWBits;
  llvm::BitVector mSWBits;
  AMDGPUSubtarget *mSTM;
  uint32_t DeviceFlag;
private:
  AMDGPUDeviceInfo::ExecutionMode
  getExecutionMode(AMDGPUDeviceInfo::Caps Caps) const;
};

} // namespace llvm
#endif // AMDILDEVICEIMPL_H