Skip to content

Commit

Permalink
Introducing DG2 and PVC support for CM
Browse files Browse the repository at this point in the history
New platforms support in CM compiler
  • Loading branch information
Konstantin Vladimirov committed Dec 14, 2021
1 parent 4494ce3 commit 2f0b0fc
Show file tree
Hide file tree
Showing 31 changed files with 3,732 additions and 11 deletions.
2 changes: 2 additions & 0 deletions include/clang/Basic/Builtins.def
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ BUILTIN(cm_scoreboard_bti, "Ui","ni")
BUILTIN(cm_scoreboard_deltas, "Q16c", "ni")
BUILTIN(cm_scoreboard_depcnt, "UiUi", "ni")
BUILTIN(cm_sbarrier, "vUi", "ni")
BUILTIN(cm_nbarrier_init, "vUc", "ni")
BUILTIN(cm_nbarrier_wait, "vUc", "ni")
BUILTIN(cm_yield, "v", "ni")
BUILTIN(cm_print_buffer, "LUi", "ni")
BUILTIN(cm_print_format_index, "icC*", "ni")
Expand Down
3 changes: 3 additions & 0 deletions include/clang/Basic/TargetOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class TargetOptions {
/// If given, the name of the target CPU to generate code for.
std::string CPU;

/// If given, the name of the stepping to generate code for.
std::string Stepping;

// If given, revision id to pass to ocloc
int RevId;

Expand Down
7 changes: 7 additions & 0 deletions include/clang/Driver/CMOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ def dump_stats_cwd : Flag<["-"], "dump-stats">, Group<cm_Group>,
HelpText<"Alias for -dump-stats=cwd">, Alias<dump_stats>, AliasArgs<["cwd"]>,
Flags<[CMOption, CC1Option, CC1AsOption]>;

def Qxcm_doubleGRF : CMIgnoredFlag<"Qxcm_doubleGRF">,
HelpText<"increase total GRF number to 256">;

def Qxcm_stepping: CMJoined<"Qxcm_stepping">,
HelpText<"Generate code taking platform stepping into account. "
"Valid only for some platforms">;

def Qxcm_revid: CMCC1Joined<"Qxcm_revid=">,
HelpText<"Pass specified revision ID to libocloc "
"Valid only for some platforms">;
Expand Down
11 changes: 11 additions & 0 deletions lib/Basic/Targets/GenX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ bool GenXTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
.Case("RKL", false)
.Case("TGLLP", false)
.Case("DG1", false)
.Case("ADLS", false)
.Case("ADLP", false)
.Case("DG2", false)
.Default(true);

NativeDoubleSupport = llvm::StringSwitch<bool>(CPU)
.Case("ICLLP", false)
.Case("TGLLP", false)
.Case("RKL", false)
.Case("DG1", false)
.Case("ADLS", false)
.Case("ADLP", false)
.Case("DG2", false)
.Default(true);

// OCL runtime specific headers support
Expand All @@ -92,6 +98,11 @@ bool GenXTargetInfo::setCPU(const std::string &Name) {
.Case("RKL", true)
.Case("DG1", true)
.Case("XEHP_SDV", true)
.Case("ADLP", true)
.Case("ADLS", true)
.Case("DG2", true)
.Case("PVC", true)
.Case("PVCXT", true)
.Default(false);

if (CPUKnown)
Expand Down
2 changes: 2 additions & 0 deletions lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BIcm_scoreboard_deltas:
case Builtin::BIcm_scoreboard_depcnt:
case Builtin::BIcm_sbarrier:
case Builtin::BIcm_nbarrier_init:
case Builtin::BIcm_nbarrier_wait:
case Builtin::BIcm_yield :
case Builtin::BIcm_print_buffer :
case Builtin::BIcm_print_format_index:
Expand Down
4 changes: 3 additions & 1 deletion lib/CodeGen/CGCM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,9 @@ void CGCMRuntime::EmitCMKernelMetadata(const FunctionDecl *FD,
getMD(llvm::ConstantInt::getNullValue(I32Ty)),
getMD(llvm::ConstantInt::getNullValue(I32Ty)), // placeholder for arg offsets
IOKinds,
ArgDescs
ArgDescs,
getMD(llvm::ConstantInt::getNullValue(I32Ty)),
getMD(llvm::ConstantInt::getNullValue(I32Ty))
};

// Add this kernel to the root.
Expand Down
21 changes: 21 additions & 0 deletions lib/CodeGen/CGCM.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,12 +634,31 @@ class CGCMRuntime {

/// \brief Postprocess cm_bfn implementation builtin
llvm::Value *HandleBuiltinBFNImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);

/// \brief Postprocess cm_srnd implementation builtin
llvm::Value *HandleBuiltinSRNDImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);
/// \brief Postprocess dpas implementation builtin.
llvm::Value *HandleBuiltinDPASImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);
/// \brief Postprocess dpas2 implementation builtin.
llvm::Value *HandleBuiltinDPAS2Impl(CMCallInfo &CallInfo, CMBuiltinKind Kind);
/// \brief Postprocess builtin cm_bf_cvt.
llvm::Value *HandleBuiltinBFCVTImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);
/// \brief Postprocess builtin cm_qf_cvt.
llvm::Value *HandleBuiltinQFCVTImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);
/// \brief Postprocess builtin cm_tf32_cvt.
llvm::Value *HandleBuiltinTF32CVTImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);
/// \brief Postprocess block 2d builtins load/store/prefetch.
llvm::Value *HandleBuiltinLSC2dImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);

/// \brief Postprocess wave 2.5 load/store
llvm::Value *HandleBuiltinLSCWaveImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);

/// \brief Postprocess BTI-based load/store/prefetch
llvm::Value *HandleBuiltinLSCImpl(CMCallInfo &CallInfo, CMBuiltinKind Kind);

/// \brief Postprocess cm_lsc_fence implementation builtins.
llvm::Value *HandleBuiltinLscFenceImpl(CMCallInfo &CallInfo,
CMBuiltinKind Kind);

/// \brief Emit 1D/2D select expression.
LValue EmitSelect(CodeGenFunction &CGF, const CMSelectExpr *E, LValue Base);
Expand Down Expand Up @@ -712,6 +731,8 @@ class CGCMRuntime {
/// Emit cm_slm_free builtin call.
llvm::Value *EmitBuiltinSLMFree(CodeGenFunction &CGF, const CallExpr *E);

/// Emit cm_nbarrier_init builtin call.
void EmitBuiltinNBarrierInit(CodeGenFunction &CGF, const CallExpr *E);

/// \brief Emit one of scatter_scaled, scatter4_scaled.
llvm::CallInst *EmitScatterScaled(CodeGenFunction &CGF, unsigned IntrinsicID,
Expand Down
Loading

0 comments on commit 2f0b0fc

Please sign in to comment.