Skip to content

Commit ccb4b0f

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (#2)
2 parents cc6e3f4 + 60def6d commit ccb4b0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1512
-1388
lines changed

clang/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,14 @@ set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
237237
set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
238238
"Enable the experimental new pass manager by default.")
239239

240-
set(CLANG_SPAWN_CC1 OFF CACHE BOOL
240+
# Clang tool executes cc1 commands in the same process after b4a99a0
241+
# It causes increasing memory consumption for compilations where several
242+
# source files are passed (for C++ application) or several build steps (e.g.
243+
# for SYCL application we have host, device and integration header step
244+
# per source file). Memory is not freed for all cc1 commands until end
245+
# This change forces clang driver use old behavior untill memory issue
246+
# is fixed.
247+
set(CLANG_SPAWN_CC1 ON CACHE BOOL
241248
"Whether clang should use a new process for the CC1 invocation")
242249

243250
# TODO: verify the values against LangStandards.def?

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7255,8 +7255,8 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
72557255
if (!ForeachArgs.empty()) {
72567256
std::string ForeachOutName =
72577257
C.getDriver().GetTemporaryPath("wrapper-linker", "txt");
7258-
const char *ForeachOutput =
7259-
C.addTempFile(C.getArgs().MakeArgString(ForeachOutName));
7258+
const char *ForeachOutput = C.addTempFile(
7259+
C.getArgs().MakeArgString(ForeachOutName), types::TY_Tempfilelist);
72607260
SmallString<128> OutOpt("--out-file-list=");
72617261
OutOpt += ForeachOutput;
72627262

clang/test/Driver/sycl-offload-tempfile.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@
1010
// RUN: not ls %t_dir/*
1111
// CHECK-TEMPFILE: clang-offload-bundler{{.*}} "-type=oo" "-targets=host-x86_64-unknown-linux-gnu,sycl-spir64-unknown-unknown-sycldevice" "-inputs=[[DIRNAME]]{{.*}}" "-outputs={{.*}},[[DIRNAME]]{{\/|\\}}[[OUTPUT3:.+\.txt]]" "-unbundle"
1212
// CHECK-TEMPFILE: llvm-link{{.*}} "@[[DIRNAME]]{{\/|\\}}[[OUTPUT3]]"
13+
14+
// RUN: mkdir -p %t_dir
15+
// RUN: env TMPDIR=%t_dir TEMP=%t_dir TMP=%t_dir \
16+
// RUN: %clang -### -fsycl -fsycl-device-code-split %s 2>&1 | \
17+
// RUN: FileCheck -DDIRNAME=%t_dir --check-prefix=CHECK-TEMPFILE-SPLIT %s
18+
// RUN: not ls %t_dir/*
19+
// CHECK-TEMPFILE-SPLIT: llvm-foreach{{.*}} "--out-file-list=[[DIRNAME]]{{\/|\\}}[[OUTPUT:.+\.txt]]" {{.*}}clang-offload-wrapper{{.*}}
20+
// CHECK-TEMPFILE-SPLIT: llvm-link{{.*}} "@[[DIRNAME]]{{\/|\\}}[[OUTPUT]]"

llvm-spirv/include/LLVMSPIRVLib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ bool writeSpirv(Module *M, const SPIRV::TranslatorOpts &Opts, std::ostream &OS,
128128
bool readSpirv(LLVMContext &C, const SPIRV::TranslatorOpts &Opts,
129129
std::istream &IS, Module *&M, std::string &ErrMsg);
130130

131+
using SpecConstInfoTy = std::pair<uint32_t, uint32_t>;
132+
void getSpecConstInfo(std::istream &IS,
133+
std::vector<SpecConstInfoTy> &SpecConstInfo);
134+
131135
/// \brief Convert a SPIRVModule into LLVM IR.
132136
/// \returns null on failure.
133137
std::unique_ptr<Module>

llvm-spirv/include/LLVMSPIRVOpts.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <cassert>
4343
#include <cstdint>
4444
#include <map>
45+
#include <unordered_map>
4546

4647
namespace SPIRV {
4748

@@ -99,12 +100,25 @@ class TranslatorOpts {
99100

100101
void enableGenArgNameMD() { GenKernelArgNameMD = true; }
101102

103+
void setSpecConst(uint32_t SpecId, uint64_t SpecValue) {
104+
ExternalSpecialization[SpecId] = SpecValue;
105+
}
106+
107+
bool getSpecializationConstant(uint32_t SpecId, uint64_t &Value) const {
108+
auto It = ExternalSpecialization.find(SpecId);
109+
if (It == ExternalSpecialization.end())
110+
return false;
111+
Value = It->second;
112+
return true;
113+
}
114+
102115
private:
103116
// Common translation options
104117
VersionNumber MaxVersion = VersionNumber::MaximumVersion;
105118
ExtensionsStatusMap ExtStatusMap;
106119
// SPIR-V to LLVM translation options
107120
bool GenKernelArgNameMD;
121+
std::unordered_map<uint32_t, uint64_t> ExternalSpecialization;
108122
};
109123

110124
} // namespace SPIRV

llvm-spirv/lib/SPIRV/OCL20ToSPIRV.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,9 +1009,23 @@ void OCL20ToSPIRV::transBuiltin(CallInst *CI, OCLBuiltinTransInfo &Info) {
10091009
unsigned ExtOp = ~0U;
10101010
if (StringRef(Info.UniqName).startswith(kSPIRVName::Prefix))
10111011
return;
1012-
if (OCLSPIRVBuiltinMap::find(Info.UniqName, &OC))
1013-
Info.UniqName = getSPIRVFuncName(OC);
1014-
else if ((ExtOp = getExtOp(Info.MangledName, Info.UniqName)) != ~0U)
1012+
if (OCLSPIRVBuiltinMap::find(Info.UniqName, &OC)) {
1013+
if (OC == OpImageRead) {
1014+
// There are several read_image* functions defined by OpenCL C spec, but
1015+
// all of them use the same SPIR-V Instruction - some of them might only
1016+
// differ by return type, so, we need to include return type into the
1017+
// mangling scheme to get them differentiated.
1018+
//
1019+
// Example: int4 read_imagei(image2d_t, sampler_t, int2)
1020+
// uint4 read_imageui(image2d_t, sampler_t, int2)
1021+
// Both functions above are represented by the same SPIR-V
1022+
// instruction: argument types are the same, only return type is
1023+
// different
1024+
Info.UniqName = getSPIRVFuncName(OC, CI->getType());
1025+
} else {
1026+
Info.UniqName = getSPIRVFuncName(OC);
1027+
}
1028+
} else if ((ExtOp = getExtOp(Info.MangledName, Info.UniqName)) != ~0U)
10151029
Info.UniqName = getSPIRVExtFuncName(SPIRVEIS_OpenCL, ExtOp);
10161030
else
10171031
return;

llvm-spirv/lib/SPIRV/OCLUtil.cpp

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,10 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
612612
addSamplerArg(1);
613613
} else if (UnmangledName.find(kOCLSubgroupsAVCIntel::Prefix) !=
614614
std::string::npos) {
615-
if (UnmangledName.find("evaluate_with_single_reference") !=
616-
std::string::npos)
615+
if (UnmangledName.find("evaluate_ipe") != std::string::npos)
616+
addSamplerArg(1);
617+
else if (UnmangledName.find("evaluate_with_single_reference") !=
618+
std::string::npos)
617619
addSamplerArg(2);
618620
else if (UnmangledName.find("evaluate_with_multi_reference") !=
619621
std::string::npos) {
@@ -637,11 +639,19 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
637639
else if (UnmangledName.find("set_inter_base_multi_reference_penalty") !=
638640
std::string::npos ||
639641
UnmangledName.find("set_inter_shape_penalty") !=
642+
std::string::npos ||
643+
UnmangledName.find("set_inter_direction_penalty") !=
640644
std::string::npos)
641645
addUnsignedArg(0);
642646
else if (UnmangledName.find("set_motion_vector_cost_function") !=
643647
std::string::npos)
644648
addUnsignedArgs(0, 2);
649+
else if (UnmangledName.find("interlaced_field_polarity") !=
650+
std::string::npos)
651+
addUnsignedArg(0);
652+
else if (UnmangledName.find("interlaced_field_polarities") !=
653+
std::string::npos)
654+
addUnsignedArgs(0, 1);
645655
else if (UnmangledName.find(kOCLSubgroupsAVCIntel::MCEPrefix) !=
646656
std::string::npos) {
647657
if (UnmangledName.find("get_default") != std::string::npos)
@@ -653,15 +663,38 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
653663
else if (UnmangledName.find("set_single_reference") !=
654664
std::string::npos)
655665
addUnsignedArg(1);
666+
else if (UnmangledName.find("set_dual_reference") != std::string::npos)
667+
addUnsignedArg(2);
668+
else if (UnmangledName.find("set_weighted_sad") != std::string::npos ||
669+
UnmangledName.find("set_early_search_termination_threshold") !=
670+
std::string::npos)
671+
addUnsignedArg(0);
656672
else if (UnmangledName.find("adjust_ref_offset") != std::string::npos)
657673
addUnsignedArgs(1, 3);
658674
else if (UnmangledName.find("set_max_motion_vector_count") !=
659675
std::string::npos ||
660676
UnmangledName.find("get_border_reached") != std::string::npos)
661677
addUnsignedArg(0);
678+
else if (UnmangledName.find("shape_distortions") != std::string::npos ||
679+
UnmangledName.find("shape_motion_vectors") !=
680+
std::string::npos ||
681+
UnmangledName.find("shape_reference_ids") !=
682+
std::string::npos) {
683+
if (UnmangledName.find("single_reference") != std::string::npos) {
684+
addUnsignedArg(1);
685+
EraseSubstring(UnmangledName, "_single_reference");
686+
} else if (UnmangledName.find("dual_reference") !=
687+
std::string::npos) {
688+
addUnsignedArgs(1, 2);
689+
EraseSubstring(UnmangledName, "_dual_reference");
690+
}
691+
} else if (UnmangledName.find("ref_window_size") != std::string::npos)
692+
addUnsignedArg(0);
662693
} else if (UnmangledName.find(kOCLSubgroupsAVCIntel::SICPrefix) !=
663694
std::string::npos) {
664-
if (UnmangledName.find("initialize") != std::string::npos)
695+
if (UnmangledName.find("initialize") != std::string::npos ||
696+
UnmangledName.find("set_intra_luma_shape_penalty") !=
697+
std::string::npos)
665698
addUnsignedArg(0);
666699
else if (UnmangledName.find("configure_ipe") != std::string::npos) {
667700
if (UnmangledName.find("_luma") != std::string::npos) {
@@ -672,7 +705,23 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
672705
addUnsignedArgs(7, 9);
673706
EraseSubstring(UnmangledName, "_chroma");
674707
}
675-
}
708+
} else if (UnmangledName.find("configure_skc") != std::string::npos)
709+
addUnsignedArgs(0, 4);
710+
else if (UnmangledName.find("set_skc") != std::string::npos) {
711+
if (UnmangledName.find("forward_transform_enable"))
712+
addUnsignedArg(0);
713+
} else if (UnmangledName.find("set_block") != std::string::npos) {
714+
if (UnmangledName.find("based_raw_skip_sad") != std::string::npos)
715+
addUnsignedArg(0);
716+
} else if (UnmangledName.find("get_motion_vector_mask") !=
717+
std::string::npos) {
718+
addUnsignedArgs(0, 1);
719+
} else if (UnmangledName.find("luma_mode_cost_function") !=
720+
std::string::npos)
721+
addUnsignedArgs(0, 2);
722+
else if (UnmangledName.find("chroma_mode_cost_function") !=
723+
std::string::npos)
724+
addUnsignedArg(0);
676725
}
677726
} else if (UnmangledName == "intel_sub_group_shuffle_down" ||
678727
UnmangledName == "intel_sub_group_shuffle_up") {
@@ -702,11 +751,14 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
702751
setArgAttr(0, SPIR::ATTR_CONST);
703752
addUnsignedArg(0);
704753
}
754+
} else if (UnmangledName.find("intel_sub_group_media_block_write") !=
755+
std::string::npos) {
756+
addUnsignedArg(3);
705757
}
706758
}
707759
// Auxiliarry information, it is expected that it is relevant at the moment
708760
// the init method is called.
709-
Function *F; // SPIRV decorated function
761+
Function *F; // SPIRV decorated function
710762
std::vector<Type *> ArgTypes; // Arguments of OCL builtin
711763
};
712764

llvm-spirv/lib/SPIRV/OCLUtil.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ template <> inline void SPIRVMap<std::string, Op, SPIRVInstruction>::init() {
747747
_SPIRV_OP(intel_sub_group_shuffle_down, SubgroupShuffleDownINTEL)
748748
_SPIRV_OP(intel_sub_group_shuffle_up, SubgroupShuffleUpINTEL)
749749
_SPIRV_OP(intel_sub_group_shuffle_xor, SubgroupShuffleXorINTEL)
750+
// Intel media_block_io builtins
751+
_SPIRV_OP(intel_sub_group_media_block_read, SubgroupImageMediaBlockReadINTEL)
752+
_SPIRV_OP(intel_sub_group_media_block_write,
753+
SubgroupImageMediaBlockWriteINTEL)
750754
#undef _SPIRV_OP
751755
}
752756

0 commit comments

Comments
 (0)