MLIR 24.0.0git
mlir::ParallelDiagnosticHandler Class Reference

This class is a utility diagnostic handler for use when multi-threading some part of the compiler where diagnostics may be emitted. More...

#include "mlir/IR/Diagnostics.h"

Public Member Functions

 ParallelDiagnosticHandler (MLIRContext *ctx)
 ~ParallelDiagnosticHandler ()
void setOrderIDForThread (size_t orderID)
 Set the order id for the current thread.
void eraseOrderIDForThread ()
 Remove the order id for the current thread.

Detailed Description

This class is a utility diagnostic handler for use when multi-threading some part of the compiler where diagnostics may be emitted.

This handler ensures a deterministic ordering to the emitted diagnostics that mirrors that of a single-threaded compilation.

Definition at line 724 of file Diagnostics.h.

Constructor & Destructor Documentation

◆ ParallelDiagnosticHandler()

ParallelDiagnosticHandler::ParallelDiagnosticHandler ( MLIRContext * ctx)

Definition at line 1176 of file Diagnostics.cpp.

◆ ~ParallelDiagnosticHandler()

ParallelDiagnosticHandler::~ParallelDiagnosticHandler ( )
default

Member Function Documentation

◆ eraseOrderIDForThread()

void ParallelDiagnosticHandler::eraseOrderIDForThread ( )

Remove the order id for the current thread.

This removes the thread from diagnostics tracking. Must be called on the same thread that set it, before the handler is destroyed.

This removes the thread from diagnostics tracking.

Definition at line 1187 of file Diagnostics.cpp.

Referenced by mlir::failableParallelForEach().

◆ setOrderIDForThread()

void ParallelDiagnosticHandler::setOrderIDForThread ( size_t orderID)

Set the order id for the current thread.

This is required to be set by each thread that will be emitting diagnostics to this handler. The orderID corresponds to the order in which diagnostics would be emitted when executing synchronously. For example, if we were processing a list of operations [a, b, c] on a single-thread. Diagnostics emitted while processing operation 'a' would be emitted before those for 'b' or 'c'. This corresponds 1-1 with the 'orderID'. The thread that is processing 'a' should set the orderID to '0'; the thread processing 'b' should set it to '1'; and so on and so forth. This provides a way for the handler to deterministically order the diagnostics that it receives given the thread that it is receiving on.

Each set must be paired with an erase on the same thread before the handler is destroyed. Nesting distinct handlers on one thread is supported; reentrant use of one handler on one thread is not.

Definition at line 1181 of file Diagnostics.cpp.

Referenced by mlir::failableParallelForEach().


The documentation for this class was generated from the following files: