@@ -805,6 +805,7 @@ bundleLinkedOutput(ArrayRef<OffloadingImage> Images, const ArgList &Args,
805
805
llvm::TimeTraceScope TimeScope (" Bundle linked output" );
806
806
switch (Kind) {
807
807
case OFK_OpenMP:
808
+ case OFK_SYCL:
808
809
return bundleOpenMP (Images);
809
810
case OFK_Cuda:
810
811
return bundleCuda (Images, Args);
@@ -940,6 +941,14 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
940
941
for (const auto &File : Input)
941
942
ActiveOffloadKindMask |= File.getBinary ()->getOffloadKind ();
942
943
944
+ // Linking images of SYCL offload kind with images of other kind is not
945
+ // supported.
946
+ // TODO: Remove the above limitation.
947
+ if ((ActiveOffloadKindMask & OFK_SYCL) &&
948
+ ((ActiveOffloadKindMask ^ OFK_SYCL) != 0 ))
949
+ return createStringError (" Linking images of SYCL offload kind with "
950
+ " images of any other kind is not supported" );
951
+
943
952
// Write any remaining device inputs to an output file.
944
953
SmallVector<StringRef> InputFiles;
945
954
for (const OffloadFile &File : Input) {
@@ -949,42 +958,6 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
949
958
InputFiles.emplace_back (*FileNameOrErr);
950
959
}
951
960
952
- // Currently, SYCL device code linking process differs from generic device
953
- // code linking.
954
- // TODO: Align SYCL device code linking with generic linking.
955
- if (ActiveOffloadKindMask & OFK_SYCL) {
956
- // Link the remaining device files using the device linker.
957
- auto OutputOrErr =
958
- linkDevice (InputFiles, LinkerArgs, ActiveOffloadKindMask);
959
- if (!OutputOrErr)
960
- return OutputOrErr.takeError ();
961
- // Output is a packaged object of device images. Unpackage the images and
962
- // copy them to Images[Kind]
963
- ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
964
- MemoryBuffer::getFileOrSTDIN (*OutputOrErr);
965
- if (std::error_code EC = BufferOrErr.getError ())
966
- return createFileError (*OutputOrErr, EC);
967
-
968
- MemoryBufferRef Buffer = **BufferOrErr;
969
- SmallVector<OffloadFile> Binaries;
970
- if (Error Err = extractOffloadBinaries (Buffer, Binaries))
971
- return std::move (Err);
972
- for (auto &OffloadFile : Binaries) {
973
- auto TheBinary = OffloadFile.getBinary ();
974
- OffloadingImage TheImage{};
975
- TheImage.TheImageKind = TheBinary->getImageKind ();
976
- TheImage.TheOffloadKind = TheBinary->getOffloadKind ();
977
- TheImage.StringData [" triple" ] = TheBinary->getTriple ();
978
- TheImage.StringData [" arch" ] = TheBinary->getArch ();
979
- TheImage.Image = MemoryBuffer::getMemBufferCopy (TheBinary->getImage ());
980
- Images[OFK_SYCL].emplace_back (std::move (TheImage));
981
- }
982
- }
983
-
984
- // Exit early if no other offload kind found (other than OFK_SYCL).
985
- if ((ActiveOffloadKindMask ^ OFK_SYCL) == 0 )
986
- return Error::success ();
987
-
988
961
// Link the remaining device files using the device linker.
989
962
auto OutputOrErr =
990
963
linkDevice (InputFiles, LinkerArgs, ActiveOffloadKindMask);
@@ -994,7 +967,7 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
994
967
// Store the offloading image for each linked output file.
995
968
for (OffloadKind Kind = OFK_OpenMP; Kind != OFK_LAST;
996
969
Kind = static_cast <OffloadKind>((uint16_t )(Kind) << 1 )) {
997
- if ((( ActiveOffloadKindMask & Kind) == 0 ) || (Kind == OFK_SYCL) )
970
+ if ((ActiveOffloadKindMask & Kind) == 0 )
998
971
continue ;
999
972
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileOrErr =
1000
973
llvm::MemoryBuffer::getFileOrSTDIN (*OutputOrErr);
@@ -1011,6 +984,7 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
1011
984
1012
985
std::scoped_lock<decltype (ImageMtx)> Guard (ImageMtx);
1013
986
OffloadingImage TheImage{};
987
+
1014
988
TheImage.TheImageKind =
1015
989
Args.hasArg (OPT_embed_bitcode) ? IMG_Bitcode : IMG_Object;
1016
990
TheImage.TheOffloadKind = Kind;
@@ -1038,11 +1012,6 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
1038
1012
A.StringData [" arch" ] > B.StringData [" arch" ] ||
1039
1013
A.TheOffloadKind < B.TheOffloadKind ;
1040
1014
});
1041
- if (Kind == OFK_SYCL) {
1042
- // TODO: Update once SYCL offload wrapping logic is available.
1043
- reportError (
1044
- createStringError (" SYCL offload wrapping logic is not available" ));
1045
- }
1046
1015
auto BundledImagesOrErr = bundleLinkedOutput (Input, Args, Kind);
1047
1016
if (!BundledImagesOrErr)
1048
1017
return BundledImagesOrErr.takeError ();
0 commit comments