Skip to content

Commit 8c50b67

Browse files
committed
Rename; Add llvm dependence
1 parent c3e186d commit 8c50b67

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

include/gc/Transforms/Passes.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def CST : Pass<"cst"> {
4545
This pass implements a constant subgraph transform.
4646
}];
4747
let constructor = "mlir::gc::createCSTPass()";
48+
let dependentDialects = [
49+
"tensor::TensorDialect",
50+
"linalg::LinalgDialect",
51+
"LLVM::LLVMDialect"];
4852
}
4953

5054
#endif // GC_DIALECT_GC_PASSES

lib/gc/Transforms/CST.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -300,45 +300,45 @@ static constexpr int DATA_SIZE_EXPANDING_THRESHOLD = 8;
300300
// void *allocator(size_t size) { return std::aligned_alloc(64, size); }
301301
// void deallocator(void *ptr) { std::free(ptr); }
302302

303-
std::shared_ptr<const_cache_proxy> create_const_cache_proxy(size_t size) {
303+
std::shared_ptr<ConstCacheProxy> createConstCacheProxy(size_t size) {
304304
// simply allocate buffer and return
305305
std::shared_ptr<void> base =
306306
std::shared_ptr<void>{std::aligned_alloc(64, size), [](void *p) {
307307
std::free(p); }};
308-
return std::make_shared<const_cache_proxy>(base, base.get(), size, true);
308+
return std::make_shared<ConstCacheProxy>(base, base.get(), size, true);
309309
}
310310

311-
size_t divide_and_ceil(size_t x, size_t y) { return (x + y - 1) / y; }
311+
size_t divideAndCeil(size_t x, size_t y) { return (x + y - 1) / y; }
312312

313313
// Manager
314-
struct const_graph_tensor_cache_manager {
314+
struct constGraphTensorCacheManager {
315315
// dnnl_graph_compiler_context *ctx;
316316

317-
uint64_t cached_tensor_global_id = 0;
317+
uint64_t cachedTensorGlobalId = 0;
318318

319319
// singleton
320-
static std::shared_ptr<const_graph_tensor_cache_manager> get() {
321-
static std::shared_ptr<const_graph_tensor_cache_manager> c =
322-
std::make_shared<const_graph_tensor_cache_manager>();
320+
static std::shared_ptr<constGraphTensorCacheManager> get() {
321+
static std::shared_ptr<constGraphTensorCacheManager> c =
322+
std::make_shared<constGraphTensorCacheManager>();
323323
return c;
324324
}
325325

326326
// alloc and set the buf_base_ and offset_ attributes of cache
327327
std::vector<uint64_t> alloc(std::vector<size_t> buffers_size) {
328328
size_t total_size = 0;
329329
for (size_t i = 0; i < buffers_size.size(); i++) {
330-
total_size += divide_and_ceil(buffers_size[i], 64) * 64;
330+
total_size += divideAndCeil(buffers_size[i], 64) * 64;
331331
}
332332
llvm::dbgs() << "Alloc total size: " << total_size << '\n';
333-
auto base = create_const_cache_proxy(total_size);
333+
auto base = createConstCacheProxy(total_size);
334334
std::vector<uint64_t> global_ids(buffers_size.size());
335335
size_t offset = 0;
336336
for (size_t i = 0; i < buffers_size.size(); i++) {
337337
llvm::dbgs() << "Alloc offset: " << offset << '\n';
338-
reg_cached_tensor(cached_tensor_global_id, base, offset);
339-
global_ids[i] = cached_tensor_global_id;
340-
++cached_tensor_global_id;
341-
offset += divide_and_ceil(buffers_size[i], 64) * 64;
338+
regCachedTensor(cachedTensorGlobalId, base, offset);
339+
global_ids[i] = cachedTensorGlobalId;
340+
++cachedTensorGlobalId;
341+
offset += divideAndCeil(buffers_size[i], 64) * 64;
342342
}
343343
return global_ids;
344344
}
@@ -541,7 +541,7 @@ void CST::runOnOperation() {
541541
buffersSize.push_back(
542542
getTensorSize(dyn_cast<TensorType>(tensor.getType())));
543543
}
544-
auto manager = const_graph_tensor_cache_manager::get();
544+
auto manager = constGraphTensorCacheManager::get();
545545
SmallVector<int64_t> globalIndexes;
546546
for (auto id : manager->alloc(buffersSize)) {
547547
globalIndexes.push_back(id);

src/gc-opt/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ set(gc_opt_libs
1717
${conversion_libs}
1818
${MLIR_LINK_COMPONENTS}
1919
GCPasses
20-
GCAnalysis)
20+
GCAnalysis
21+
GCCpuRuntime)
2122

2223
if(GC_MLIR_CXX_FLAGS)
2324
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_MLIR_CXX_FLAGS}")

0 commit comments

Comments
 (0)