Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
65b8f15
Update tests
ggeorgakoudis Feb 11, 2026
4ed1c0a
Add JitEngineInfoRegistry component
ggeorgakoudis Feb 11, 2026
2863332
Update tests
ggeorgakoudis Feb 11, 2026
74eb872
Deprecate proteus init/finalize
ggeorgakoudis Feb 11, 2026
509d74e
Update JitEngineInfoRegistry
ggeorgakoudis Feb 11, 2026
189b8e7
Use JitEngineInfoRegistry to store information
ggeorgakoudis Feb 11, 2026
5c72db3
Remove init/finalize for host jit engine
ggeorgakoudis Feb 11, 2026
eb118f1
Remove ensureProteusInitialize from host jit engine
ggeorgakoudis Feb 11, 2026
db23660
Remove ensureProteusInitialized from dsl frontend
ggeorgakoudis Feb 11, 2026
de2c696
Remove ensureProteusInitialized from cpp frontend
ggeorgakoudis Feb 11, 2026
a7183a6
Use JitEngineInfoRegistry in device jit engine and update cleanup
ggeorgakoudis Feb 11, 2026
d491266
Update error message
ggeorgakoudis Feb 11, 2026
79c20be
Remove ObjectCacheRegistry and update users
ggeorgakoudis Feb 11, 2026
208309c
Add a cleanup callback at MPI finalization for the MPI cache
ggeorgakoudis Feb 11, 2026
2a7fd7c
Fixup: remove comments from Init.h
ggeorgakoudis Feb 11, 2026
018d0df
Fix MPI cache finalization with sentinel sends and a shutdown tag
ggeorgakoudis Feb 11, 2026
34ccc0b
Fix more MPI finalization using ack messages
ggeorgakoudis Feb 11, 2026
cf18e21
Fix some more MPI cache finalization
ggeorgakoudis Feb 11, 2026
6eca23c
Simplify comm thread and avoid shutdown races
ggeorgakoudis Feb 11, 2026
55e0f8c
initialize 'Running' to false
ZwFink Feb 12, 2026
3458578
Add exception handling for comm thread
ggeorgakoudis Feb 12, 2026
3a021d2
Fixup: fix easy comments
ggeorgakoudis Feb 12, 2026
126b160
Fixup: remove special status of rank 0 main thread
ggeorgakoudis Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/proteus/Frontend/Dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct DispatchResult;
class Dispatcher {
protected:
TargetModelType TargetModel;
ObjectCacheChain *ObjectCache = nullptr;
std::unique_ptr<ObjectCacheChain> ObjectCache;

Dispatcher(const std::string &Name, TargetModelType TM);

Expand Down
6 changes: 3 additions & 3 deletions include/proteus/Init.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

namespace proteus {

bool &proteusIsInitialized();
void ensureProteusInitialized();

[[deprecated("it is a no-op and will be removed in a future version.")]]
void init();
[[deprecated("it is a no-op and will be removed in a future version.")]]
void finalize();

void enable();
void disable();

Expand Down
16 changes: 5 additions & 11 deletions src/include/proteus/impl/Caching/MPISharedStorageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "proteus/impl/CompiledLibrary.h"
#include "proteus/impl/Hashing.h"

#include <mpi.h>

Check failure on line 18 in src/include/proteus/impl/Caching/MPISharedStorageCache.h

View workflow job for this annotation

GitHub Actions / cpp-linter

src/include/proteus/impl/Caching/MPISharedStorageCache.h:18:10 [clang-diagnostic-error]

'mpi.h' file not found

#include <atomic>
#include <chrono>
Expand All @@ -40,28 +40,21 @@
CommThreadHandle &operator=(const CommThreadHandle &) = delete;

template <typename Callable> void start(Callable &&ThreadFunc) {
if (Running.load())
if (isRunning())
return;

ShutdownFlag.store(false, std::memory_order_release);
Thread = std::make_unique<std::thread>(std::forward<Callable>(ThreadFunc));
Running.store(true, std::memory_order_release);
Running = true;
}

void stop();
void join();

bool isRunning() const;

bool shutdownRequested() const;

bool waitOrShutdown(std::chrono::milliseconds Timeout);

private:
std::unique_ptr<std::thread> Thread;
mutable std::mutex Mutex;
std::condition_variable CondVar;
std::atomic<bool> ShutdownFlag{false};
std::atomic<bool> Running{false};
bool Running = false;
};

class MPICommHandle {
Expand Down Expand Up @@ -131,6 +124,7 @@
const std::string StorageDirectory;
const std::string Label;
const int Tag;
const int ShutdownTag;
MPICommHandle CommHandle;
CommThreadHandle CommThread;
bool Finalized = false;
Expand Down
38 changes: 0 additions & 38 deletions src/include/proteus/impl/Caching/ObjectCacheRegistry.h

This file was deleted.

42 changes: 28 additions & 14 deletions src/include/proteus/impl/CompilerAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class CompilationResult {

class CompilerAsync {
public:
static CompilerAsync &instance(int NumThreads) {
static CompilerAsync Singleton{NumThreads};
return Singleton;
}

void compile(CompilationTask &&CT) {
std::unique_lock Lock{Mutex};
// Get HashValue before the move of CT.
Expand All @@ -76,6 +71,13 @@ class CompilerAsync {

Count++;
std::unique_ptr<MemoryBuffer> ObjBuf = CT.compile();

// Ensure threads are joined before static objects are destroyed during
// program exit. This static is initialized after COMGR's own statics
// (triggered by compile() above), so C++ reverse destruction order
// guarantees ~ShutdownGuard runs first.
static ShutdownGuard Guard{this};

Lock.lock();
CompilationResultMap.at(CT.getHashValue())->set(std::move(ObjBuf));
Lock.unlock();
Expand All @@ -97,7 +99,8 @@ class CompilerAsync {
CondVar.notify_all();

for (auto &Thread : Threads)
Thread.join();
if (Thread.joinable())
Thread.join();

Threads.clear();
}
Expand Down Expand Up @@ -138,22 +141,33 @@ class CompilerAsync {
return ObjBuf;
}

CompilerAsync(int NumThreads) {
Active = true;
for (int I = 0; I < NumThreads; ++I)
Threads.emplace_back(&CompilerAsync::run, this);
}

~CompilerAsync() { joinAllThreads(); }

private:
// Joins threads before static objects are destroyed at exit (e.g.,
// COMGR/HIPRTC). Must be constructed after the first compile()) so that
// reverse destruction order ensures this runs first.
struct ShutdownGuard {
CompilerAsync *CA;
~ShutdownGuard() {
if (CA)
CA->joinAllThreads();
}
};

bool Active;
std::mutex Mutex;
std::condition_variable CondVar;
std::unordered_map<HashT, std::unique_ptr<CompilationResult>>
CompilationResultMap;
std::deque<CompilationTask> Worklist;
std::vector<std::thread> Threads;

CompilerAsync(int NumThreads) {
Active = true;
for (int I = 0; I < NumThreads; ++I)
Threads.emplace_back(&CompilerAsync::run, this);
}

~CompilerAsync() { joinAllThreads(); }
};

} // namespace proteus
Expand Down
Loading