-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
- Loading branch information
Showing
16 changed files
with
125 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//=-- ESIMDRemoveOptnoneNoinline.cpp - remove optnone/noinline for ESIMD --=// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//=------------------------------------------------------------------------=// | ||
// The GPU backend for ESIMD does not support debugging and we often see crashes | ||
// or wrong answers if we do not optimize. Remove optnone and noinline from | ||
// ESIMD functions so users at least can run their programs and get the | ||
// right answer. | ||
//=------------------------------------------------------------------------=// | ||
|
||
#define DEBUG_TYPE "ESIMDRemoveOptnoneNoinlinePass" | ||
|
||
#include "llvm/IR/Function.h" | ||
#include "llvm/IR/Module.h" | ||
#include "llvm/Pass.h" | ||
#include "llvm/SYCLLowerIR/ESIMD/ESIMDUtils.h" | ||
#include "llvm/SYCLLowerIR/ESIMD/LowerESIMD.h" | ||
#include "llvm/Support/Debug.h" | ||
|
||
using namespace llvm; | ||
using namespace llvm::esimd; | ||
|
||
cl::opt<bool> AllowOptnoneNoinline( | ||
"esimd-allow-optnone-noinline", llvm::cl::Optional, llvm::cl::Hidden, | ||
llvm::cl::desc("Allow optnone and noinline."), llvm::cl::init(false)); | ||
|
||
PreservedAnalyses ESIMDRemoveOptnoneNoinlinePass::run(Module &M, | ||
ModuleAnalysisManager &) { | ||
if (AllowOptnoneNoinline) | ||
return PreservedAnalyses::all(); | ||
|
||
// TODO: Remove this pass once VC supports debugging. | ||
bool Modified = false; | ||
for (auto &F : M.functions()) { | ||
if (!isESIMD(F) || F.hasFnAttribute("CMGenxSIMT")) | ||
continue; | ||
F.removeFnAttr(Attribute::OptimizeNone); | ||
F.removeFnAttr(Attribute::NoInline); | ||
Modified = true; | ||
} | ||
return Modified ? PreservedAnalyses::none() : PreservedAnalyses::all(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; This ensures we remove optnone from ESIMD functions unless they are SIMT or we didn't split ESIMD code out. | ||
; RUN: sycl-post-link -split-esimd -lower-esimd -S < %s -o %t.table | ||
; RUN: FileCheck %s -input-file=%t_esimd_0.ll --check-prefixes CHECK,CHECK-ESIMD-SPLIT | ||
|
||
; RUN: sycl-post-link -lower-esimd -S < %s -o %t1.table | ||
; RUN: FileCheck %s -input-file=%t1_esimd_0.ll --check-prefixes CHECK,CHECK-NO-ESIMD-SPLIT | ||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
define dso_local spir_func void @esimd() #0 !sycl_explicit_simd !0 { | ||
; CHECK: void @esimd() #[[#ESIMDAttr:]] | ||
ret void | ||
} | ||
|
||
define dso_local spir_func void @esimd_simt() #1 !sycl_explicit_simd !0 { | ||
; CHECK: void @esimd_simt() #[[#ESIMDSIMTAttr:]] | ||
ret void | ||
} | ||
|
||
define dso_local spir_func void @sycl() #0 { | ||
; CHECK: spir_func void @sycl() #[[#ESIMDAttr]] | ||
ret void | ||
} | ||
; CHECK-ESIMD-SPLIT: attributes #[[#ESIMDAttr]] = | ||
; CHECK-ESIMD-SPLIT-NOT: optnone | ||
; CHECK-NO-ESIMD-SPLIT: attributes #[[#ESIMDAttr]] = {{{.*}}optnone{{.*}}} | ||
; CHECK: attributes #[[#ESIMDSIMTAttr]] = {{{.*}}optnone | ||
; CHECK-SAME: "CMGenxSIMT" | ||
; CHECK-SAME: } | ||
attributes #0 = { noinline optnone convergent } | ||
attributes #1 = { noinline optnone convergent "CMGenxSIMT"} | ||
!0 = !{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import platform | ||
|
||
config.substitutions.append(("%clang_O0", "-O0 -mllvm -esimd-allow-optnone-noinline")) |