Skip to content

Commit f4b4a84

Browse files
authored
[SYCL][Fusion][NoSTL][NFC] Move SYCLModuleInfo to its own header (#12413)
Move `SYCLModuleInfo` class to its own header under the `common` directory (because it has users from `jit-compiler` and `passes`). _This PR is part of a series of changes to remove uses of STL classes in the kernel fusion interface to prevent ABI issues in the future._ Signed-off-by: Julian Oppermann <[email protected]>
1 parent c873fe2 commit f4b4a84

File tree

5 files changed

+54
-30
lines changed

5 files changed

+54
-30
lines changed

sycl-fusion/common/include/Kernel.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
#include "DynArray.h"
1313

1414
#include <algorithm>
15-
#include <array>
1615
#include <cassert>
1716
#include <cstdint>
1817
#include <cstring>
19-
#include <string>
20-
#include <vector>
18+
#include <functional>
19+
#include <type_traits>
2120

2221
namespace jit_compiler {
2322

@@ -350,33 +349,6 @@ struct SYCLKernelInfo {
350349
: Name{KernelName}, Args{NumArgs}, Attributes{}, NDR{}, BinaryInfo{} {}
351350
};
352351

353-
///
354-
/// Represents a SPIR-V translation unit containing SYCL kernels by the
355-
/// KernelInfo for each of the contained kernels.
356-
class SYCLModuleInfo {
357-
public:
358-
using KernelInfoList = std::vector<SYCLKernelInfo>;
359-
360-
void addKernel(SYCLKernelInfo &Kernel) { Kernels.push_back(Kernel); }
361-
362-
KernelInfoList &kernels() { return Kernels; }
363-
364-
bool hasKernelFor(const std::string &KernelName) {
365-
return getKernelFor(KernelName) != nullptr;
366-
}
367-
368-
SYCLKernelInfo *getKernelFor(const std::string &KernelName) {
369-
auto It =
370-
std::find_if(Kernels.begin(), Kernels.end(), [&](SYCLKernelInfo &K) {
371-
return K.Name == KernelName.c_str();
372-
});
373-
return (It != Kernels.end()) ? &*It : nullptr;
374-
}
375-
376-
private:
377-
KernelInfoList Kernels;
378-
};
379-
380352
} // namespace jit_compiler
381353

382354
#endif // SYCL_FUSION_COMMON_KERNEL_H

sycl-fusion/common/lib/ModuleInfo.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//==------------ ModuleInfo.h - Manages kernel info for the JIT ------------==//
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+
#ifndef SYCL_FUSION_COMMON_MODULEINFO_H
10+
#define SYCL_FUSION_COMMON_MODULEINFO_H
11+
12+
#include "Kernel.h"
13+
14+
#include <algorithm>
15+
#include <string>
16+
#include <vector>
17+
18+
namespace jit_compiler {
19+
20+
///
21+
/// Represents a SPIR-V translation unit containing SYCL kernels by the
22+
/// KernelInfo for each of the contained kernels.
23+
class SYCLModuleInfo {
24+
public:
25+
using KernelInfoList = std::vector<SYCLKernelInfo>;
26+
27+
void addKernel(SYCLKernelInfo &Kernel) { Kernels.push_back(Kernel); }
28+
29+
KernelInfoList &kernels() { return Kernels; }
30+
31+
bool hasKernelFor(const std::string &KernelName) {
32+
return getKernelFor(KernelName) != nullptr;
33+
}
34+
35+
SYCLKernelInfo *getKernelFor(const std::string &KernelName) {
36+
auto It =
37+
std::find_if(Kernels.begin(), Kernels.end(), [&](SYCLKernelInfo &K) {
38+
return K.Name == KernelName.c_str();
39+
});
40+
return (It != Kernels.end()) ? &*It : nullptr;
41+
}
42+
43+
private:
44+
KernelInfoList Kernels;
45+
};
46+
47+
} // namespace jit_compiler
48+
49+
#endif // SYCL_FUSION_COMMON_MODULEINFO_H

sycl-fusion/jit-compiler/lib/fusion/FusionPipeline.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define SYCL_FUSION_JIT_COMPILER_FUSION_FUSIONPIPELINE_H
1111

1212
#include "Kernel.h"
13+
#include "ModuleInfo.h"
1314
#include "llvm/IR/Module.h"
1415

1516
namespace jit_compiler {

sycl-fusion/passes/kernel-fusion/SYCLKernelFusion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define SYCL_FUSION_PASSES_SYCLKERNELFUSION_H
1111

1212
#include "Kernel.h"
13+
#include "ModuleInfo.h"
1314
#include "target/TargetFusionInfo.h"
1415
#include "llvm/ADT/ArrayRef.h"
1516
#include "llvm/ADT/SmallVector.h"

sycl-fusion/passes/kernel-info/SYCLKernelInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "llvm/Passes/PassPlugin.h"
1414

1515
#include "Kernel.h"
16+
#include "ModuleInfo.h"
1617

1718
///
1819
/// Analysis pass to make the SYCLModuleInfo available to other

0 commit comments

Comments
 (0)