Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
StorageCache.hpp
Go to the documentation of this file.
1//===-- StorageCache.hpp -- Storage cache header --===//
2//
3// Part of the Proteus Project, under the Apache License v2.0 with LLVM
4// Exceptions. See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef PROTEUS_JITSTOREDCACHE_HPP
12#define PROTEUS_JITSTOREDCACHE_HPP
13
14#include <cstdint>
15
16#include <llvm/Support/MemoryBufferRef.h>
17
19#include "proteus/Hashing.hpp"
20
21namespace proteus {
22
23using namespace llvm;
24
25// NOTE: Storage cache assumes that stored code is re-usable across runs!
26// TODO: Source code changes should invalidate the cache. Also, if storing
27// assembly (PTX) or binary (ELF), then device globals may have different
28// addresses that render it invalid. In this case, store LLVM IR to re-link
29// globals.
31public:
32 StorageCache(const std::string &Label);
33
34 std::unique_ptr<CompiledLibrary> lookup(HashT &HashValue);
35
36 void store(HashT &HashValue, MemoryBufferRef ObjBufRef);
37
38 void storeDynamicLibrary(HashT &HashValue, const SmallString<128> &Path);
39
40 void printStats();
41
42private:
43 uint64_t Hits = 0;
44 uint64_t Accesses = 0;
45 const std::string StorageDirectory;
46 const std::string Label;
47 const std::string DistributedRank;
48};
49
50} // namespace proteus
51
52#endif
Definition Hashing.hpp:20
Definition StorageCache.hpp:30
std::unique_ptr< CompiledLibrary > lookup(HashT &HashValue)
Definition StorageCache.cpp:41
void store(HashT &HashValue, MemoryBufferRef ObjBufRef)
Definition StorageCache.cpp:66
void printStats()
Definition StorageCache.cpp:86
void storeDynamicLibrary(HashT &HashValue, const SmallString< 128 > &Path)
Definition StorageCache.cpp:76
Definition Helpers.h:138
Definition StorageCache.cpp:24