Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
MPIStorageCache.h
Go to the documentation of this file.
1//===-- MPIStorageCache.h -- MPI storage cache base class 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// Base class for MPI-based storage caches. Provides shared infrastructure for
10// store forwarding, disk persistence, and communication thread lifecycle.
11// Subclasses implement lookup() and optionally override handleMessage() to
12// handle additional message types.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef PROTEUS_MPISTORAGECACHE_H
17#define PROTEUS_MPISTORAGECACHE_H
18
23
24#include <atomic>
25#include <cstdint>
26#include <memory>
27#include <string>
28
29namespace proteus {
30
32public:
33 MPIStorageCache(const std::string &Label);
34 ~MPIStorageCache() override;
35
36 void store(const HashT &HashValue, const CacheEntry &Entry) override;
37 void finalize() override;
38 void printStats() override;
39 uint64_t getHits() const override { return Hits; }
40 uint64_t getAccesses() const override { return Accesses; }
41
42protected:
43 void startCommThread();
44 std::unique_ptr<CompiledLibrary> lookupFromDisk(const HashT &HashValue);
45 virtual void handleMessage(MPI_Status &Status, MPITag Tag);
46
47 void forwardToWriter(const HashT &HashValue, const CacheEntry &Entry);
48 void saveToDisk(const HashT &HashValue, const char *Data, size_t Size,
49 bool IsDynLib);
50
51 uint64_t Hits = 0;
52 uint64_t Accesses = 0;
53 const std::string StorageDirectory;
54 const std::string Label;
57
58private:
59 void communicationThreadMain();
60 void handleStoreMessage(MPI_Status &Status);
61
62 std::atomic<bool> ShutdownRequested{false};
63 bool Finalized = false;
64};
65
66} // namespace proteus
67
68#endif
Manages the lifecycle of a background communication thread.
Definition MPIHelpers.h:36
Definition Hashing.h:21
RAII wrapper for MPI communicator with thread safety checks.
Definition MPIHelpers.h:62
Definition MPIStorageCache.h:31
uint64_t Hits
Definition MPIStorageCache.h:51
std::unique_ptr< CompiledLibrary > lookupFromDisk(const HashT &HashValue)
Definition MPIStorageCache.cpp:199
void finalize() override
Definition MPIStorageCache.cpp:56
uint64_t Accesses
Definition MPIStorageCache.h:52
const std::string StorageDirectory
Definition MPIStorageCache.h:53
void startCommThread()
Definition MPIStorageCache.cpp:95
const std::string Label
Definition MPIStorageCache.h:54
uint64_t getAccesses() const override
Definition MPIStorageCache.h:40
MPICommHandle CommHandle
Definition MPIStorageCache.h:55
uint64_t getHits() const override
Definition MPIStorageCache.h:39
virtual void handleMessage(MPI_Status &Status, MPITag Tag)
Definition MPIStorageCache.cpp:159
void saveToDisk(const HashT &HashValue, const char *Data, size_t Size, bool IsDynLib)
Definition MPIStorageCache.cpp:180
void store(const HashT &HashValue, const CacheEntry &Entry) override
Definition MPIStorageCache.cpp:82
void printStats() override
Definition MPIStorageCache.cpp:215
CommThreadHandle CommThread
Definition MPIStorageCache.h:56
void forwardToWriter(const HashT &HashValue, const CacheEntry &Entry)
Definition MPIStorageCache.cpp:101
Definition ObjectCache.h:39
Definition MemoryCache.h:26
MPITag
Definition MPIHelpers.h:27
Definition ObjectCache.h:27