Skip to content

Commit 57ffbf7

Browse files
committed
up
Signed-off-by: Chen, Sheng S <[email protected]>
1 parent 5c1bc98 commit 57ffbf7

File tree

8 files changed

+130
-129
lines changed

8 files changed

+130
-129
lines changed

clang/lib/DPCT/DPCT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ int runDPCT(int argc, const char **argv) {
14811481
ReplSYCL);
14821482
}
14831483
if (!ReplSYCL.empty()) {
1484-
CollectDepsResult(ReplSYCL);
1484+
CollectDepLib(ReplSYCL);
14851485
}
14861486
// OC_Action: Analysis mode
14871487
if (DpctGlobalInfo::isAnalysisModeEnabled()) {

clang/lib/DPCT/FileGenerator/GenFiles.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ int saveNewFiles(clang::tooling::RefactoringTool &Tool,
998998
clang::dpct::RT_CUDAWithCodePin))
999999
return RewriteStatus;
10001000
}
1001-
ShowDepsResult(llvm::outs());
1001+
PrintRecommendLibs(llvm::outs());
10021002
// Print the in-root path and the number of processed files
10031003
size_t ProcessedFileNumber;
10041004
if (ProcessAll) {
@@ -1034,7 +1034,7 @@ int saveNewFiles(clang::tooling::RefactoringTool &Tool,
10341034
} else {
10351035
ReportMsg += "\n";
10361036
}
1037-
1037+
10381038
ReportMsg += "\n";
10391039
ReportMsg += DiagRef;
10401040

clang/lib/DPCT/MigrationReport/RecommandLibraries.cpp

Lines changed: 0 additions & 60 deletions
This file was deleted.

clang/lib/DPCT/MigrationReport/RecommandLibraries.h

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--------------- Diagnostics.inc --------------------------------------===//
1+
//===--------------- RecommandLibrariesVersion.inc --------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,12 +8,12 @@
88
// - Name: Obj name
99
// Feature: Feature name
1010
// SupportedVersion: Time stamp of component
11-
// ComponentType: Component type.
11+
// LibType: Component type.
1212
// ReplacementText: The migrated Replacement Text
1313
// Description: Details of the feature.
1414

1515
#ifndef RECOMMENDLIBRARY
1616
#define RECOMMENDLIBRARY
1717
#endif
1818
// Example:
19-
// RECOMMENDLIBRARY(FreeQuery, "SYCL free function query", "Time", ComponentType::DPCPP, "this_work_item", "See https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/proposed/sycl_ext_oneapi_free_function_kernels.asciidoc for more details.")
19+
// RECOMMENDLIBRARY(FreeQuery, "SYCL free function query", "2025", LibType::DPCPP, "this_work_item", "See https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/proposed/sycl_ext_oneapi_free_function_kernels.asciidoc for more details.")
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//===--------------- RecommendLibraries.cpp ------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "RecommandLibraries.h"
10+
#include "FileGenerator/GenFiles.h"
11+
#include "Statics.h"
12+
#include <string>
13+
#include <unordered_map>
14+
15+
namespace clang {
16+
namespace dpct {
17+
struct RecommendLib {
18+
std::string Feature;
19+
std::string SupportedVersion;
20+
std::string ReplacementText;
21+
LibType CompType;
22+
std::string Description;
23+
24+
RecommendLib() = default;
25+
RecommendLib(std::unordered_map<LibType, RecommendLib> &Table,
26+
std::string Feature, std::string SupportedVersion, LibType CT,
27+
std::string ReplacementText, std::string Description)
28+
: Feature(Feature), SupportedVersion(SupportedVersion),
29+
ReplacementText(ReplacementText), CompType(CT),
30+
Description(Description) {
31+
Table[CT] = *this;
32+
}
33+
};
34+
static std::unordered_map<clang::dpct::LibType, clang::dpct::RecommendLib>
35+
RecommendLibs;
36+
std::vector<clang::dpct::RecommendLib> RecommendLibList;
37+
38+
#define RECOMMENDLIBRARY(NAME, Feature, VERSION, COMPTYPE, REPLACEMENT, MSG) \
39+
RecommendLib DepRecommend_##NAME(RecommendLibs, Feature, VERSION, COMPTYPE, \
40+
REPLACEMENT, MSG);
41+
#include "RecommandLibrariesVersion.inc"
42+
43+
void CollectDepLib(ReplTy &Repls) {
44+
for (auto Entry : RecommendLibs) {
45+
auto &Lib = Entry.second;
46+
[&]() {
47+
for (auto Repl : Repls) {
48+
for (auto Item : Repl.second) {
49+
if (Item.getReplacementText().str().find(Lib.ReplacementText) !=
50+
std::string::npos) {
51+
RecommendLibList.push_back(Lib);
52+
return;
53+
}
54+
}
55+
}
56+
}();
57+
}
58+
}
59+
60+
std::string LibTypeToString(LibType version) {
61+
switch (version) {
62+
case LibType::DPCPP:
63+
return "oneAPI DPC++ compiler Open Source Version";
64+
case LibType::oneDPL:
65+
return "oneAPI DPC++ Library Open Source Version";
66+
case LibType::oneMath:
67+
return "oneAPI Math Library Open Source Version";
68+
case LibType::oneCCL:
69+
return "oneAPI Collective Communications Library Open Source Version";
70+
case LibType::oneDNNL:
71+
return "oneAPI Deep Neural Network Library Open Source Version";
72+
case LibType::ISHMEM:
73+
return "oneAPI SHMEM Library Open Source Version";
74+
default:
75+
return "Unknown Component Type ";
76+
}
77+
}
78+
79+
void PrintRecommendLibs(llvm::raw_ostream &OStream) {
80+
if (RecommendLibList.empty())
81+
return;
82+
if (DpctGlobalInfo::isAnalysisModeEnabled())
83+
OStream << llvm::raw_ostream::Colors::BLUE;
84+
85+
OStream << "Recommand Library Dependencies of SYCL Project:\n";
86+
87+
if (DpctGlobalInfo::isAnalysisModeEnabled())
88+
OStream << llvm::raw_ostream::Colors::RESET;
89+
for (auto &Status : RecommendLibList) {
90+
OStream << " - The " + Status.Feature + " is supported in " +
91+
LibTypeToString(Status.CompType) + " and after " +
92+
Status.SupportedVersion + ". " + Status.Description + "\n";
93+
}
94+
}
95+
96+
97+
} // namespace dpct
98+
} // namespace clang
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===--------------- RecommendLibraries.h --------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#ifndef RECOMMEND_LIBRARIES_H
9+
#define RECOMMEND_LIBRARIES_H
10+
11+
#include "AnalysisInfo.h"
12+
#include "FileGenerator/GenFiles.h"
13+
#include "llvm/Support/raw_ostream.h"
14+
#include <string>
15+
#include <unordered_map>
16+
17+
namespace clang {
18+
namespace dpct {
19+
enum class LibType { DPCPP, oneDPL, oneMath, oneCCL, oneDNNL, ISHMEM };
20+
21+
void CollectDepLib(ReplTy &MainSrcFilesRepls);
22+
void PrintRecommendLibs(llvm::raw_ostream &OStream);
23+
} // namespace dpct
24+
} // namespace clang
25+
#endif // RECOMMEND_LIBRARIES_H

clang/lib/DPCT/MigrationReport/Statics.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ std::unordered_map<std::string, std::array<unsigned int, 3>> LOCStaticsMap;
2929
// unsigned int -> Times met
3030
std::map<std::string, unsigned int> SrcAPIStaticsMap;
3131

32-
extern std::vector<clang::dpct::DependencyStatus> DepStatusVec;
33-
3432
int VerboseLevel = VL_NonVerbose;
3533

3634
void StaticsInfo::printMigrationRules(
@@ -367,7 +365,7 @@ class AnalysisModeStats {
367365
}
368366
LineStream(OS, Indent) << LastMsg;
369367

370-
ShowDepsResult(OS);
368+
PrintRecommendLibs(OS);
371369
}
372370

373371
static void recordApisOrTypes(SourceLocation SL, StringRef Name,

0 commit comments

Comments
 (0)