Home | History | Annotate | Download | only in R600
      1 //===---- AMDILDevice.h - Define Device Data for AMDGPU -----*- C++ -*------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //==-----------------------------------------------------------------------===//
      9 //
     10 /// \file
     11 /// \brief Interface for the subtarget data classes.
     12 //
     13 /// This file will define the interface that each generation needs to
     14 /// implement in order to correctly answer queries on the capabilities of the
     15 /// specific hardware.
     16 //===----------------------------------------------------------------------===//
     17 #ifndef AMDILDEVICEIMPL_H
     18 #define AMDILDEVICEIMPL_H
     19 #include "AMDIL.h"
     20 #include "llvm/ADT/BitVector.h"
     21 
     22 namespace llvm {
     23   class AMDGPUSubtarget;
     24   class MCStreamer;
     25 //===----------------------------------------------------------------------===//
     26 // Interface for data that is specific to a single device
     27 //===----------------------------------------------------------------------===//
     28 class AMDGPUDevice {
     29 public:
     30   AMDGPUDevice(AMDGPUSubtarget *ST);
     31   virtual ~AMDGPUDevice();
     32 
     33   // Enum values for the various memory types.
     34   enum {
     35     RAW_UAV_ID   = 0,
     36     ARENA_UAV_ID = 1,
     37     LDS_ID       = 2,
     38     GDS_ID       = 3,
     39     SCRATCH_ID   = 4,
     40     CONSTANT_ID  = 5,
     41     GLOBAL_ID    = 6,
     42     MAX_IDS      = 7
     43   } IO_TYPE_IDS;
     44 
     45   /// \returns The max LDS size that the hardware supports.  Size is in
     46   /// bytes.
     47   virtual size_t getMaxLDSSize() const = 0;
     48 
     49   /// \returns The max GDS size that the hardware supports if the GDS is
     50   /// supported by the hardware.  Size is in bytes.
     51   virtual size_t getMaxGDSSize() const;
     52 
     53   /// \returns The max number of hardware constant address spaces that
     54   /// are supported by this device.
     55   virtual size_t getMaxNumCBs() const;
     56 
     57   /// \returns The max number of bytes a single hardware constant buffer
     58   /// can support.  Size is in bytes.
     59   virtual size_t getMaxCBSize() const;
     60 
     61   /// \returns The max number of bytes allowed by the hardware scratch
     62   /// buffer.  Size is in bytes.
     63   virtual size_t getMaxScratchSize() const;
     64 
     65   /// \brief Get the flag that corresponds to the device.
     66   virtual uint32_t getDeviceFlag() const;
     67 
     68   /// \returns The number of work-items that exist in a single hardware
     69   /// wavefront.
     70   virtual size_t getWavefrontSize() const = 0;
     71 
     72   /// \brief Get the generational name of this specific device.
     73   virtual uint32_t getGeneration() const = 0;
     74 
     75   /// \brief Get the stack alignment of this specific device.
     76   virtual uint32_t getStackAlignment() const;
     77 
     78   /// \brief Get the resource ID for this specific device.
     79   virtual uint32_t getResourceID(uint32_t DeviceID) const = 0;
     80 
     81   /// \brief Get the max number of UAV's for this device.
     82   virtual uint32_t getMaxNumUAVs() const = 0;
     83 
     84 
     85   // API utilizing more detailed capabilities of each family of
     86   // cards. If a capability is supported, then either usesHardware or
     87   // usesSoftware returned true.  If usesHardware returned true, then
     88   // usesSoftware must return false for the same capability.  Hardware
     89   // execution means that the feature is done natively by the hardware
     90   // and is not emulated by the softare.  Software execution means
     91   // that the feature could be done in the hardware, but there is
     92   // software that emulates it with possibly using the hardware for
     93   // support since the hardware does not fully comply with OpenCL
     94   // specs.
     95 
     96   bool isSupported(AMDGPUDeviceInfo::Caps Mode) const;
     97   bool usesHardware(AMDGPUDeviceInfo::Caps Mode) const;
     98   bool usesSoftware(AMDGPUDeviceInfo::Caps Mode) const;
     99   virtual std::string getDataLayout() const;
    100   static const unsigned int MAX_LDS_SIZE_700 = 16384;
    101   static const unsigned int MAX_LDS_SIZE_800 = 32768;
    102   static const unsigned int WavefrontSize = 64;
    103   static const unsigned int HalfWavefrontSize = 32;
    104   static const unsigned int QuarterWavefrontSize = 16;
    105 protected:
    106   virtual void setCaps();
    107   BitVector mHWBits;
    108   llvm::BitVector mSWBits;
    109   AMDGPUSubtarget *mSTM;
    110   uint32_t DeviceFlag;
    111 private:
    112   AMDGPUDeviceInfo::ExecutionMode
    113   getExecutionMode(AMDGPUDeviceInfo::Caps Caps) const;
    114 };
    115 
    116 } // namespace llvm
    117 #endif // AMDILDEVICEIMPL_H
    118