8000 [SYCL][FE][Driver] Implement floating point accuracy control by zahiraam · Pull Request #8280 · intel/llvm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[SYCL][FE][Driver] Implement floating point accuracy control #8280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 55 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
79792b3
Implement floating point accuracy.
zahiraam Feb 9, 2023
c3029ee
Responded to review comments and added more to the implementation.
zahiraam Feb 13, 2023
fa51800
Added option falt-math-library and fixed a few things with fpbuiltin-…
zahiraam Feb 14, 2023
b584e3d
Added a cc1 option triggered by the fp-accuracy option.
zahiraam Mar 1, 2023
ec2dfbc
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam Apr 4, 2023
be478d8
Remove TargetInfoLibrary dependency.
zahiraam Apr 6, 2023
4c23010
Fix a few things.
zahiraam Apr 6, 2023
db8c415
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam Apr 6, 2023
2bcd2a8
Fix a few things.
zahiraam Apr 6, 2023
bdf5dbe
Adding code to support the option.
zahiraam Apr 18, 2023
d796b5f
Fix formatting issues and remove unused code.
zahiraam Apr 18, 2023
6c005d8
Fix format issues.
zahiraam Apr 18, 2023
b93d9ec
Respond to review.
zahiraam Apr 18, 2023
17eb30f
Fix typo.
zahiraam Apr 18, 2023
4ffd86f
Add a group to the diag and fixed typo.
zahiraam Apr 18, 2023
bd458b9
Fixed typo.
zahiraam Apr 18, 2023
80c131a
Hooking BE code with FE.
zahiraam Apr 24, 2023
faae1a0
Responded to review.
8000 zahiraam Apr 25, 2023
bbabbb5
Fix format.
zahiraam Apr 25, 2023
ef29dfc
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam Apr 25, 2023
8aabc41
Responded to review comments.
zahiraam Apr 25, 2023
6681fc2
Fixed Lit test failures.
zahiraam Apr 26, 2023
20fd09b
Fixed sincos issue and did some code refactoring.
zahiraam Apr 26, 2023
300d2fe
Remove FPAccuracyMap.
zahiraam Apr 27, 2023
1e148b3
Added testing for the all the fpbuiltin.
zahiraam May 1, 2023
4f6089a
Fix format.
zahiraam May 1, 2023
5a61b28
Fix format.
zahiraam May 1, 2023
f02d393
Fix format.
zahiraam May 1, 2023
061ca9f
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam May 1, 2023
edb89ce
Added default mode.
zahiraam May 5, 2023
ec3be13
Responded to reviews.
zahiraam May 5, 2023
9cce8b7
Fix format.
zahiraam May 5, 2023
2ea8d5a
Added support for math-errno.
zahiraam May 8, 2023
7abea95
Fixed diag comment.
zahiraam May 8, 2023
773f1ed
Fix lit test.
zahiraam May 8, 2023
68c9a70
Fixed Diag.
zahiraam May 9, 2023
a7c7546
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam May 9, 2023
bffc1fd
Responded to review comments.
zahiraam May 9, 2023
7900b87
Responded to review comments.
zahiraam May 18, 2023
a71e5f2
Responded to review comments.
zahiraam May 19, 2023
a05458f
Responded to review comments.
zahiraam May 25, 2023
02831e8
Responded to review comments.
zahiraam May 26, 2023
680bd47
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam May 30, 2023
c3f2ca2
Fix format.
zahiraam May 30, 2023
10715d3
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam May 30, 2023
a3803db
Re-wrote the condition to make it more readable. Edited the comment
zahiraam May 31, 2023
98ed36d
Responded to review comments.
zahiraam Jun 6, 2023
cdfec2c
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam Jun 6, 2023
831aa36
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam Jun 8, 2023
a0adb9e
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam Jun 9, 2023
d3d470e
Responded to review for CmakeLists.txt.
zahiraam Jun 12, 2023
e08362e
Responded to review about the AttrList.
zahiraam Jun 12, 2023
6d5890d
Fixed typo.
zahiraam Jun 12, 2023
7d3c976
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam Jun 12, 2023
9c86522
Merge remote-tracking branch 'remote/sycl' into FPAccuracy
zahiraam Jun 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ CODEGENOPT(VirtualFunctionElimination, 1, 0) ///< Whether to apply the dead
/// virtual function elimination
/// optimization.

/// Whether accuracy levels for math library functions are requested by the
/// user. These accuracy levels will then be expressed in terms of ULPs.
CODEGENOPT(FPAccuracy, 1, 0)

/// Whether to use public LTO visibility for entities in std and stdext
/// namespaces. This is enabled by clang-cl's /MT and /MTd flags.
CODEGENOPT(LTOVisibilityPublicStd, 1, 0)
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticCommonKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ def warn_stack_clash_protection_inline_asm : Warning<
def warn_slh_does_not_support_asm_goto : Warning<
"speculative load hardening does not protect functions with asm goto">,
InGroup<DiagGroup<"slh-asm-goto">>;

def err_drv_incompatible_options : Error<
"the combination of '%0' and '%1' is incompatible">;
}

// Sema && Serialization
Expand Down
9 changes: 7 additions & 2 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def err_drv_no_cuda_libdevice : Error<
"via '--cuda-path', or pass '-nocudalib' to build without linking with "
"libdevice">;

def warn_function_fp_accuracy_already_set : Warning <
"floating point accuracy value of '%0' has already been assigned to "
"function '%1'">,
InGroup<DiagGroup<"fp-accuracy-already-set">>;
def err_drv_no_rocm_device_lib : Error<
"cannot find ROCm device library%select{| for %1|for ABI version %1}0; provide its path via "
"'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build "
Expand Down Expand Up @@ -141,8 +145,9 @@ def err_drv_invalid_unwindlib_name : Error<
"invalid unwind library name in argument '%0'">;
def err_drv_incompatible_unwindlib : Error<
"--rtlib=libgcc requires --unwindlib=libgcc">;
def err_drv_incompatible_options : Error<
"the combination of '%0' and '%1' is incompatible">;
def err_drv_incompatible_fp_accuracy_options : Error<
"floating point accuracy requirements cannot be guaranteed when '-fmath-errno' "
"is enabled; use '-fno-math-errno' to enable floating point accuracy control">;
def err_drv_invalid_stdlib_name : Error<
"invalid library name in argument '%0'">;
def err_drv_invalid_output_with_multiple_archs : Error<
Expand Down
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/FPOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ OPTION(AllowReciprocal, bool, 1, NoSignedZero)
OPTION(AllowApproxFunc, bool, 1, AllowReciprocal)
OPTION(FPEvalMethod, LangOptions::FPEvalMethodKind, 2, AllowApproxFunc)
OPTION(Float16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, FPEvalMethod)
OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, FPEvalMethod)
OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, Float16ExcessPrecision)
OPTION(FPAccuracy, LangOptions::FPAccuracyKind, 3, BFloat16ExcessPrecision)
#undef OPTION
1 change: 1 addition & 0 deletions clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ BENIGN_ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Default, "FP Ex
BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 2, FEM_UnsetOnCommandLine, "FP type used for floating point arithmetic")
ENUM_LANGOPT(Float16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for Float16 arithmetic")
ENUM_LANGOPT(BFloat16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Stan 1E0A dard, "Intermediate truncation behavior for BFloat16 arithmetic")
BENIGN_ENUM_LANGOPT(FPAccuracy, FPAccuracyKind, 3, FPA_Default, "Accuracy for floating point operations and library functions")
LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")
LANGOPT(HexagonQdsp6Compat , 1, 0, "hexagon-qdsp6 backward compatibility")
LANGOPT(ObjCAutoRefCount , 1, 0, "Objective-C automated reference counting")
Expand Down
13 changes: 13 additions & 0 deletions clang/include/clang/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ class LangOptions : public LangOptionsBase {

enum ExcessPrecisionKind { FPP_Standard, FPP_Fast, FPP_None };

enum FPAccuracyKind {
FPA_Default,
FPA_High,
FPA_Medium,
FPA_Low,
FPA_Sycl,
FPA_Cuda,
};

/// Possible exception handling behavior.
enum class ExceptionHandlingKind { None, SjLj, WinEH, DwarfCFI, Wasm };

Expand Down Expand Up @@ -509,6 +518,10 @@ class LangOptions : public LangOptionsBase {
/// records.
std::string OptRecordFile;

std::string FPAccuracyVal;
using FPAccuracyFuncMapTy = std::map<std::string, std::string>;
FPAccuracyFuncMapTy FPAccuracyFuncMap;

LangOptions();

/// Set language defaults for the given input language and
Expand Down
15 changes: 15 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,13 @@ def ffp_exception_behavior_EQ : Joined<["-"], "ffp-exception-behavior=">, Group<
Values<"ignore,maytrap,strict">, NormalizedValuesScope<"LangOptions">,
NormalizedValues<["FPE_Ignore", "FPE_MayTrap", "FPE_Strict"]>,
MarshallingInfoEnum<LangOpts<"FPExceptionMode">, "FPE_Default">;
def ffp_accuracy_EQ : Joined<["-"], "ffp-accuracy=">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Specifies the required accuracy for floating-point operations and library calls.">,
Values<"default,high,medium,low,sycl,cuda">, NormalizedValuesScope<"LangOptions">,
NormalizedValues<["FPA_Default", "FPA_High", "FPA_Medium", "FPA_Low", "FPA_Sycl", "FPA_Cuda"]>,
MarshallingInfoEnum<LangOpts<"FPAccuracy">, "FPA_Default">;
def ffp_builtin_accuracy_EQ : Joined<["-"], "ffp-builtin-accuracy=">, Group<f_Group>, Flags<[CC1Option]>;

defm fast_math : BoolFOption<"fast-math",
LangOpts<"FastMath">, DefaultFalse,
PosFlag<SetTrue, [CC1Option, CoreOption, FC1Option, FlangOption], "Allow aggressive, lossy floating-point optimizations",
Expand Down Expand Up @@ -7020,6 +7027,14 @@ class CLRemainingArgsJoined<string name> : Option<["/", "-"], name,
// (We don't put any of these in cl_compile_Group as the options they alias are
// already in the right group.)

// INTEL_CUSTOMIZATION
def _SLASH_Qfp_accuracy_EQ : CLJoined<"Qfp-accuracy=">,
Alias<ffp_accuracy_EQ>;
def _SLASH_Qfp_accuracy_COL : CLJoined<"Qfp-accuracy:">,
Alias<ffp_accuracy_EQ>,HelpText<"Specifies the required accuracy for "
"floating-point operations and library calls.">;
// END INTEL_CUSTOMIZATION

def _SLASH_Brepro : CLFlag<"Brepro">,
HelpText<"Do not write current time into COFF output (breaks link.exe /incremental)">,
Alias<mno_incremental_linker_compatible>;
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ class CompilerInvocation : public CompilerInvocationRefBase,
std::vector<std::string> &Includes,
DiagnosticsEngine &Diags);

static void ParseFpAccuracyArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
DiagnosticsEngine &Diags);

/// Generate command line options from LangOptions.
static void GenerateLangArgs(const LangOptions &Opts,
SmallVectorImpl<const char *> &Args,
Expand Down
Loading
0