codegen_opencl.h 1.35 KB
Newer Older
1 2 3
/*!
 *  Copyright (c) 2017 by Contributors
 * \file codegen_opencl.h
4
 * \brief Generate OpenCL device code.
5 6 7 8 9 10 11 12 13 14 15 16
 */
#ifndef TVM_CODEGEN_CODEGEN_OPENCL_H_
#define TVM_CODEGEN_CODEGEN_OPENCL_H_

#include <tvm/codegen.h>
#include <tvm/packed_func_ext.h>
#include <string>
#include "./codegen_c.h"

namespace tvm {
namespace codegen {

17
class CodeGenOpenCL final : public CodeGenC {
18
 public:
19
  CodeGenOpenCL();
20
  void AddFunction(LoweredFunc f);
21
  // override print thread tag.
22
  void InitFuncState(LoweredFunc f) final;
23
  void BindThreadIndex(const IterVar& iv) final;  // NOLINT(*)
24
  void PrintStorageScope(const std::string& scope, std::ostream& os) final; // NOLINT(*)
25
  void PrintStorageSync(const Call* op) final;  // NOLINT(*)
26
  void PrintType(Type t, std::ostream& os) const final; // NOLINT(*)
27 28
  std::string GetVecLoad(Type t, const Variable* buffer,
                         Expr base) final;
29
  void PrintVecStore(const Variable* buffer,
30 31
                     Type t, Expr base,
                     const std::string& value) final;  // NOLINT(*)
32 33 34
  // the address of load/store
  void PrintVecAddr(const Variable* buffer, Type t,
                    Expr base, std::ostream& os);  // NOLINT(*)
35 36
  // overload visitor
  void VisitExpr_(const Broadcast* op, std::ostream& os) final; // NOLINT(*)
37 38 39 40 41 42
};

}  // namespace codegen
}  // namespace tvm

#endif  // TVM_CODEGEN_CODEGEN_OPENCL_H_