-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
featureNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Milestone
Description
Create a wrapper for a generic runtime backed by an opaque implementation of a parallel computation model, like MPI (multi-process), Tokio (async), or Rayon (multi-thread).
The internals of the Runtime
can be implemented with Tokio. That is, a Tokio runtime will be encapsulated in a custom Runtime
type, and the Tokio runtime will be the coordinator of the parallel implementation's workers. All Runtime
calls should be synchronous and blocking, but internally, the Tokio runtime might make asynchronous / non-blocking calls to the underlying model.
In this sense, this is the first part of four things:
- Synchronous runtime wrapper
- Asynchronous generic coordinator
- Bindings to parallel impls. (OpenMPI, rayon, more Tokio, etc.)
- Thread-safe database implementation
Example
/// Available types of runtime. All of these assume a shared file system.
enum Runtime {
ThreadPool { threads: u32 },
Async { tasks: u32 },
MPI { nodes: u32 },
}
/// Arguments to job functions.
struct Args<G, D> {
game: &G,
db: &mut D,
}
/// Solve the game.
fn solve<G: ..., D: ...>(game: &G, db: &mut D) -> Result<()> {
let rt = Runtime::initialize(Runtime::MPI(30))?;
rt.dashboard(Interface::Web)?;
rt.route_logs(LOG_FILE)?;
let mut graph = Graph::<JobID>::new(); // Partition solving jobs (JobID = Partition #)
let mut set = Vec::<JobID>::new(); // Exploration jobs (JobID = State)
starts = stochastic_exploration(game, db);
graph = rt.independent(
ExploreArgs { game, db },
explore_job::<G, D>,
jobs: set,
)?;
rt.dependent(
SolveArgs { game, db },
solve_job::<G, D>,
jobs: graph,
)?;
}
/// Explore the game tree.
fn explore_job<G: ..., D: ...>(args: Args<G, D>, target: JobID) -> Result<()> { ... }
/// Solve a single partition.
fn solve_job<G: ..., D: ...>(args: Args<G, D>, target: JobID) -> Result<()> { ... }
/// Sample random states in the game tree.
fn stochastic_exploration<G: ..., D: ...>(args: Args<G, D>) -> Result<()> { ... }
Recommended Courses (UC Berkeley)
If you can't tell whether this is out of your scope, we recommend the following experience:
- CS 61B (minimum)
- CS 61C (minimum)
- CS 162
- CS 267
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed