Docs
Classes
- Diagnostics
Class that handles the diagnostics for the MPI Core. It is used to profile the time taken by different functions in the MPI Core.
- MPI_Request
Class that is returned by the non-blocking functions in the MPI Core. It can be used to test if the request is done or to wait for the request to be done.
- Packet
Class for representing a packet that can be sent between NodeRouter instances.
- NodeRouter
Class for a NodeRouter can be used to send and receive packets between workers on this browser tab.
- Map2D
Class for a map that can be accessed by two keys. All operations are O(1).
- ProducerConsumer
Class for a producer-consumer buffer that can be used to send and receive objects between workers.
- SmartDashboard
Class that handles the SmartDashboard for the MPI Core. SmartDashboard is used to send real-time telemetry data to the main UI process.
Functions
- MPI_Barrier() ⇒
Promise.<void>
MPI_Barrier is a synchronization function that blocks the processes until all processes have reached the barrier. This function is blocking, and it will only return after all the processes have reached the barrier.
If optimization flag is set, SSMR (Single Source Multiple Recipients) will be utilized where applicable.
- MPI_Bcast(data_ptr, root) ⇒
Promise.<void>
MPI_Bcast broadcasts data from the root process to all other processes. This function is blocking, and it will only return after all the processes have received the data.
If optimization flag is set, SSMR (Single Source Multiple Recipients) will be utilized where applicable.
Another optimizatin made is sending parallel messages. If there is a lot of bcasts from the same gr_id, then the later ones don't need to wait for the earlier ones to propogate every other gr_id. The root can move on whenever it's done within the local gr. This parallelism maintains correctness and can offer up to 300x speedup.
- MPI_Ibcast(data_ptr, root)
MPI_Ibcast broadcasts data from the root process to all other processes. This function is non-blocking, and it will return immediately after the data has been broadcasted. The user can use the MPI_Request object to test if the broadcast is done, or to wait for the broadcast to be done.
If optimization flag is set, SSMR (Single Source Multiple Recipients) will be utilized where applicable.
- MPI_Gather(send_ptr, recv_ptr, root) ⇒
Promise.<void>
MPI_Gather is a collective operation that gathers data from all processes and stores it in the root process. All processes must provide the same count of data.
- MPI_Allgather(send_ptr, recv_ptr) ⇒
Promise.<void>
MPI_Allgather is a collective operation that gathers data from all processes and stores it in all processes. All processes must provide the same count of data.
- MPI_Gatherv(send_ptr, recv_ptr, counts, offsets, root) ⇒
Promise.<void>
MPI_Gatherv is a collective operation that gathers data from all processes and stores it in the root process. Each process can provide a different count of data. This information must be provided.
- MPI_Allgatherv(send_ptr, recv_ptr, counts, offsets) ⇒
Promise.<void>
MPI_Allgatherv is a collective operation that gathers data from all processes and stores it in all processes. Each process can provide a different count of data. This information must be provided.
- reschedule(callback)
This function is used to take a function off of the event queue and add it to the back of the event queue.
Sometimes, the main function is too long, and it blocks any message events from being processed. This function allows the main function to be paused and other events to be processed. After other queued events are processed, the main function is added back to the end of event queue to continue processing.
- flush_telemetry()
Sometimes the main function is too long and prevents the telemetry from being flushed. This function manually flushes the telemetry.
- finish_setup()
This function is used to finish setting up this worker after the initial configuration is received.
- on_init_message(event)
This function is used to receive a message from the main process in the initialization phase. After initialization is complete, this function is no longer used.
- main(main_fn, worker_self)
The entry point for user code. The user supplies its main function, as well as the worker object itself.
This function sets up all the necessary components for the worker to run.
- MPI_Comm_rank(rank_ptr)
MPI function to obtain the rank of the current process.
- MPI_Comm_size(size_ptr)
MPI function to obtain the number of processes.
- MPI_Init()
MPI function to initialize the MPI environment.
- MPI_Finalize()
MPI function to finalize and finish the MPI environment.
- box(data) ⇒
Box
Function to wrap data in a box.
- unbox(box) ⇒
any
Function to unbox data from a box.
- MPI_Test(request) ⇒
Promise.<boolean>
MPI_Test tests if the request is done. Regardless of whether the request is done or not, the callback should immediately return a boolean.
- MPI_Wait(request) ⇒
Promise.<void>
MPI_Wait waits for the request to be done. The callback should return a promise that resolves when the request is done.
- MPI_Send(data_ptr, dest_pid, start, count) ⇒
Promise.<void>
MPI_Send sends data to another process. This function is blocking, and it will only return after the receiver confirms that it has received the data.
start and count are optional parameters that allow the user to specify a slice of the array to send. Only use these parameters if the data is an array.
- MPI_Isend(data_ptr, dest_pid, start, count) ⇒
Promise.<MPI_Request>
MPI_Isend sends data to another process. This function is non-blocking, and it will return immediately after sending the data. The user can use the MPI_Request object to test if the buffer is ready to be reused.
start and count are optional parameters that allow the user to specify a slice of the array to send. Only use these parameters if the data is an array.
- MPI_Recv(data_ptr, src_pid, start, count) ⇒
Promise.<void>
MPI_Recv receives data from another process. This function is blocking, and it will only return after the data has been received.
start and count are optional parameters that allow the user to specify a slice of the array to receive. Only use these parameters if the data is an array.
- MPI_Irecv(data_ptr, src_pid, start, count) ⇒
Promise.<MPI_Request>
MPI_Irecv receives data from another process. This function is non-blocking, and it will return immediately after receiving the data. The user can use the MPI_Request object to test if the receive is done, or to wait for the receive to be done.
start and count are optional parameters that allow the user to specify a slice of the array to receive. Only use these parameters if the data is an array.
- MPI_Reduce(send_ptr, recv_ptr, operation) ⇒
Promise.<void>
MPI_Reduce is a collective operation that combines the data from all processes in the communicator and returns the result to a single process. The root process will receive the result.
The operation is function performed on the data pointed to by the data_ptr. The operation is defined by the operation parameter.
The optimized version does a local reduce and then send the local results to the root process for a final reduce in order to minimize communication bandwidth.
TODO: Future idea: If not a crossbar interconnect, try to reduce along the way.
- MPI_Allreduce_local_optimized(send_ptr, recv_ptr, operation) ⇒
Promise.<void>
This function only performs a all_reduce operation in the local group of processes. It detects the type of interconnect and uses the appropriate strategy to perform the all_reduce operation most efficiently. The speedup is more significant when the array size is large.
Specifically, it uses the ring allreduce strategy for crossbar and ring interconnects, and the tree allreduce strategy for the tree interconnect.
- MPI_Allreduce(send_ptr, recv_ptr, operation) ⇒
Promise.<void>
MPI_Allreduce is a collective operation that combines the data from all processes in the communicator and returns the result to all processes. The result is stored in the recv_ptr box.
If the optimized flag is set, and the operation is limited to the local group of processes, then the allreduce operation is performed using the optimized strategy depending on the interconnect type. If the operation spans multiple groups of processes, then the a local reduce is performed first, and a secondary reduce is performed between the groups to save bandwidth. This can have many times speedup when the array size or number of processors is large.
- MPI_Scatter(send_ptr, recv_ptr, root) ⇒
Promise.<void>
MPI_Scatter is a collective operation that scatters data from the root process to all other processes. All processes must provide the same count of data.
- MPI_Scatterv(send_ptr, recv_ptr, root) ⇒
Promise.<void>
MPI_Scatterv is a collective operation that scatters data from the root process to all other processes. All processes must provide the same count of data.
- partition(count, num_proc) ⇒
Object
This function partitions the work equally to the number of processors.
For example, if there is 6 work and 4 processors, the function will return [2, 2, 1, 1] and [0, 2, 4, 5].
Note that it will not return [2, 2, 2, 0] and [0, 2, 4, 6] because the work is not evenly distributed. The result will have difference of at most 1.
- make_wrap(n) ⇒
function
This function makes a wrap function that wraps the index around the array.
- create_crossbar(num_nodes) ⇒
Object
This function creates channels between all pairs of workers. This function does not create the channels object, but rather pairs of ints that represent the workers that are connected.
This function also provides the routing table for each node, so they know where to send messages when they need to communicate with different nodes.
- create_ring(num_nodes) ⇒
Object
This function creates channels between some pairs of workers. This function does not create the channels object, but rather pairs of ints that represent the workers that are connected.
The pattern being created is a ring structure.
This function also provides the routing table for each node, so they know where to send messages when they need to communicate with different nodes.
For example, if we have 4 workers, the following channels will be created:
0 <---> 1
1 <---> 2
2 <---> 3
3 <---> 0
For N workers, the number of channels created is O(N)
The longest path between any two workers is O(N)
- create_tree_pow_of_2(num_nodes) ⇒
Object
This function creates channels between some pairs of workers. This function does not create the channels object, but rather pairs of ints that represent the workers that are connected.
The pattern being created is a tree structure.
This function also provides the routing table for each node, so they know where to send messages when they need to communicate with different nodes.
Important note: This function only works when the number of workers is a power of 2.
For example, if we have 8 workers, the following channels will be created:
0 <---> 1
2 <---> 3
4 <---> 5
6 <---> 7
0 <---> 2
4 <---> 6
0 <---> 4
For N workers, the number of channels created is O(N)
The longest path between any two workers is O(log(N))
- create_tree(num_nodes) ⇒
Object
This function creates channels between some pairs of workers. This function does not create the channels object, but rather pairs of ints that represent the workers that are connected.
The pattern being created is a tree structure.
This function also provides the routing table for each node, so they know where to send messages when they need to communicate with different nodes.
This function works for any number of workers, even if it is not a power of 2.
For example, if we have 7 workers, the following channels will be created:
0 <---> 1
2 <---> 3
4 <---> 5
0 <---> 2
4 <---> 6
0 <---> 4
For N workers, the number of channels created is O(N)
The longest path between any two workers is O(log(N))
Typedefs
- Box :
Object
A box holds data. This is used to pass data between functions by reference.
- Config :
Object
config
- Key_A :
any
- Key_B :
any
- SmartDashboardType :
'pie'
|'progress'
|'graph'
|'string'
Diagnostics
Class that handles the diagnostics for the MPI Core. It is used to profile the time taken by different functions in the MPI Core.
Kind: global class
new Diagnostics()
Nothing is done here because the configuration is done by the configure function.
diagnostics.add_send
Diagnostic function to count the number of sends in node_router.
Kind: instance property of Diagnostics
diagnostics.add_recv
Diagnostic function to count the number of receives in node_router.
Kind: instance property of Diagnostics
diagnostics.profile ⇒ function
This function is a decorator that profiles the time taken by a function.
Kind: instance property of Diagnostics
Returns: function
- A new function that profiles the time taken by the original function.
Param | Type | Description |
---|---|---|
fn | function |
The function to profile. |
diagnostics.flush
This function is used to flush the diagnostics to the SmartDashboard. It sends the total time used by each function and the delta time used by each function.
Kind: instance property of Diagnostics
diagnostics.configure(smartdashboard, enabled, period)
This function is used to configure the diagnostics. The configuration is done here after the object is created because many functions use the profile function of this class before the smartdashboard is created.
Kind: instance method of Diagnostics
Param | Type | Default | Description |
---|---|---|---|
smartdashboard | SmartDashboard |
The SmartDashboard object to send the diagnostics to. | |
enabled | boolean |
Whether the diagnostics are collected or not. | |
period | number |
250 |
The period at which the diagnostics are sent to the SmartDashboard. |
MPI_Request
Class that is returned by the non-blocking functions in the MPI Core. It can be used to test if the request is done or to wait for the request to be done.
Kind: global class
- MPI_Request
- new MPI_Request(done)
- .set_test_callback(callback) ⇒
MPI_Request
- .set_wait_callback(callback) ⇒
MPI_Request
- .test() ⇒
Promise.<boolean>
- .wait() ⇒
new MPI_Request(done)
Param | Type | Default | Description |
---|---|---|---|
done | boolean |
false |
Whether the request is done or not. |
mpI_Request.set_test_callback(callback) ⇒ MPI_Request
Set the test callback for the MPI_Request. This callback is used to test if the request is done. Regardless of whether the request is done or not, the callback should immediately return a boolean.
Kind: instance method of MPI_Request
Returns: MPI_Request
- The current MPI_Request object.
Param | Type | Description |
---|---|---|
callback | function |
The callback to set. |
mpI_Request.set_wait_callback(callback) ⇒ MPI_Request
Set the wait callback for the MPI_Request. This callback is used to wait for the request to be done. The callback should return a promise that resolves when the request is done.
Kind: instance method of MPI_Request
Returns: MPI_Request
- The current MPI_Request object.
Param | Type | Description |
---|---|---|
callback | function |
The callback to set. |
mpI_Request.test() ⇒ Promise.<boolean>
Test if the request is done. Regardless of whether the request is done or not, the callback should immediately return a boolean.
Kind: instance method of MPI_Request
Returns: Promise.<boolean>
- A promise that resolves when the test is done, indicating whether the request is done.
mpI_Request.wait() ⇒
Wait for the request to be done. The callback should return a promise that resolves when the request is done.
Kind: instance method of MPI_Request
Returns: A promise that resolves when the request is done.
Packet
Class for representing a packet that can be sent between NodeRouter instances.
new Packet(src_pid, dest_pid_arr, tag, data)
Param | Type | Description |
---|---|---|
src_pid | number |
The source pid of the packet. |
dest_pid_arr | Array.<number> |
The destination pids of the packet. |
tag | string |
The tag of the packet. |
data | any |
The data of the packet. |
NodeRouter
Class for a NodeRouter can be used to send and receive packets between workers on this browser tab.
Kind: global class
new NodeRouter(num_proc, my_pid, local_channels, global_channel)
Param | Type | Description |
---|---|---|
num_proc | number |
number of workers |
my_pid | number |
the pid of this worker |
local_channels | Record.<number, MessagePort> |
channels to peers on the my local node |
global_channel | WorkerGlobalScope |
channel to main manager on this node |
nodeRouter.send ⇒ Promise.<void>
Send a packet to the destination pids. This is a non-blocking function that returns immediately after sending the packet. The receiving worker can only receive this packet if it is listening for packets with the same tag or ANY tag.
Send to your own pid if you want to send to the global router.
Kind: instance property of NodeRouter
Returns: Promise.<void>
- A promise that resolves when the packet is sent.
Param | Type | Description |
---|---|---|
dest_pid_arr | Array.<number> |
The destination pids of the packet. |
tag | string |
The tag of the packet. Default is "NA". |
data | any |
The data of the packet. Default is "". |
nodeRouter.receive ⇒ Promise.<Packet>
Receive a packet from a specific source pid with a specific tag. This is a blocking function that waits until a packet is received from the specified source pid with the specified tag.
Kind: instance property of NodeRouter
Returns: Promise.<Packet>
- A promise that resolves to the received packet.
Param | Type | Description |
---|---|---|
src_pid | number |
The source pid of the packet. Default is null, which means any source pid. |
tag | string |
The tag of the packet. Default is null, which means any tag. |
nodeRouter.receive_if_available ⇒ Promise.<Packet>
Receive a packet from a specific source pid with a specific tag. This is a non-blocking function that returns immediately if a packet is not available from the specified source pid with the specified tag.
Kind: instance property of NodeRouter
Returns: Promise.<Packet>
- A promise that resolves to the received packet if available, otherwise null.
Param | Type | Description |
---|---|---|
src_pid | number |
The source pid of the packet. Default is null, which means any source pid. |
tag | string |
The tag of the packet. Default is null, which means any tag. |
nodeRouter.peek ⇒ Promise.<Packet>
Peek at the packet from a specific source pid with a specific tag. This is a non-blocking function that returns immediately if a packet is not available from the specified source pid with the specified tag.
This function will not remove the packet from the buffer.
Kind: instance property of NodeRouter
Returns: Promise.<Packet>
- A promise that resolves to the received packet if available, otherwise null.
Param | Type | Description |
---|---|---|
src_pid | number |
The source pid of the packet. Default is null, which means any source pid. |
tag | string |
The tag of the packet. Default is null, which means any tag. |
Map2D
Class for a map that can be accessed by two keys. All operations are O(1).
Kind: global class
- Map2D
- new Map2D()
- .add(a, b, value)
- .get(a, b) ⇒
any
- .pop(a, b) ⇒
any
new Map2D()
The ab_map sorts values by a, then by b. ab_map: a -> b -> [value_arr]
The ba_map sorts values by b, then by a. ba_map: b -> a -> [value_arr]
When adding a value, it is added to both maps. When searching for a value with a certain a_key, the ab_map is searched. When searching for a value with a certain b_key, the ba_map is searched. When a value is popped, it is popped from both maps.
At the cost of twice as many pointers, this allows every operation to be O(1).
map2D.add(a, b, value)
Add a value to the map with a and b keys.
Complexity: O(1)
Kind: instance method of Map2D
Param | Type | Description |
---|---|---|
a | Key_A |
The first key. |
b | Key_B |
The second key. |
value | any |
The value to add. |
map2D.get(a, b) ⇒ any
Get a value from the map with a and b keys. If any key is null, it is a wildcard. Wildcard keys mean it will return the first value it sees, ignoring the requirement of that key.
Complexity: O(1)
Kind: instance method of Map2D
Returns: any
- The value found. If no value is found, it returns null.
Param | Type | Default | Description |
---|---|---|---|
a | Key_A |
|
The first key. Default is null, which means wildcard. |
b | Key_B |
|
The second key. Default is null, which means wildcard. |
map2D.pop(a, b) ⇒ any
Pop a value from the map with a and b keys. If any key is null, it is a wildcard. Wildcard keys mean it will return the first value it sees, ignoring the requirement of that key.
If a value is foundk, the value is removed from the data structure.
Complexity: O(1)
Kind: instance method of Map2D
Returns: any
- The value found. If no value is found, it returns null.
Param | Type | Default | Description |
---|---|---|---|
a | Key_A |
|
The first key. Default is null, which means wildcard. |
b | Key_B |
|
The second key. Default is null, which means wildcard. |
ProducerConsumer
Class for a producer-consumer buffer that can be used to send and receive objects between workers.
Kind: global class
new ProducerConsumer()
Uses two Map2D objects to store the buffer and the callbacks. This way, each call to produce and consume is O(1).
TLDR: For each msg that arrives, it O(1) searches for matching callbacks in callbacks Map2D that can match it. If no one can take it, the msg will be added to the msgs Map2D.
For each consumer callback that is received, it O(1) searches for a msg that can match it. If no such msg is found, the callback will be added to the callbacks Map2D.
producerConsumer.produce(object) ⇒ Promise.<void>
Add a packet to the buffer. If a callback is waiting for a packet with the a matching pid and tag, the callback will be called with the packet. Otherwise, the packet will be added to the buffer.
Kind: instance method of ProducerConsumer
Returns: Promise.<void>
- A promise that resolves when the packet is added to the buffer.
Param | Type | Description |
---|---|---|
object | Packet |
The object to add to the buffer. |
producerConsumer.consume(src_pid, tag) ⇒ Promise.<Packet>
Get a packet from the buffer. If a packet is available with the a matching pid and tag, the packet will be returned. Otherwise, the consumer will wait until a packet is available.
Kind: instance method of ProducerConsumer
Returns: Promise.<Packet>
- A promise that resolves to the received packet.
Param | Type | Default | Description |
---|---|---|---|
src_pid | number |
|
The source pid of the packet. Default is null, which means any source pid. |
tag | string |
null |
The tag of the packet. Default is null, which means any tag. |
producerConsumer.consume_if_available(src_pid, tag) ⇒ Promise.<Packet>
Get a packet from the buffer if available. If a packet is available with the a matching pid and tag, the packet will be returned. Otherwise, null will be returned immediately. This is a non-blocking function.
Kind: instance method of ProducerConsumer
Returns: Promise.<Packet>
- A promise that resolves to the received packet if available, otherwise null.
Param | Type | Default | Description |
---|---|---|---|
src_pid | number |
|
The source pid of the packet. Default is null, which means any source pid. |
tag | string |
null |
The tag of the packet. Default is null, which means any tag. |
producerConsumer.peek(src_pid, tag) ⇒ Promise.<Packet>
Peek at the packet from the buffer. This is a non-blocking function that returns immediately. This function will not remove the packet from the buffer.
Kind: instance method of ProducerConsumer
Returns: Promise.<Packet>
- A promise that resolves to the received packet if available, otherwise null.
Param | Type | Default | Description |
---|---|---|---|
src_pid | number |
|
The source pid of the packet. Default is null, which means any source pid. |
tag | string |
null |
The tag of the packet. Default is null, which means any tag. |
SmartDashboard
Class that handles the SmartDashboard for the MPI Core. SmartDashboard is used to send real-time telemetry data to the main UI process.
Kind: global class
smartDashboard.putPie(name, dict, downsample)
This function is used to put a pie chart in the SmartDashboard.
Downsample means to only keep the most recent data point. This is useful for real-time, but should be turned off for logs.
Kind: instance method of SmartDashboard
Param | Type | Default | Description |
---|---|---|---|
name | string |
The name of the pie chart. | |
dict | Record.<string, number> |
The data for the pie chart. | |
downsample | boolean |
true |
Whether to downsample the data or not. |
smartDashboard.putProgress(name, value, downsample)
This function is used to put a progress bar in the SmartDashboard.
Downsample means to only keep the most recent data point. This is useful for real-time, but should be turned off for logs.
Kind: instance method of SmartDashboard
Param | Type | Default | Description |
---|---|---|---|
name | string |
The name of the progress bar. | |
value | number |
The value of the progress bar. | |
downsample | boolean |
true |
Whether to downsample the data or not. |
smartDashboard.putGraph(name, value, downsample)
This function is used to put a graph in the SmartDashboard.
Downsample means to only keep the most recent data point. This is useful for real-time, but should be turned off for logs.
Kind: instance method of SmartDashboard
Param | Type | Default | Description |
---|---|---|---|
name | string |
The name of the graph. | |
value | number |
The value of the graph. | |
downsample | boolean |
true |
Whether to downsample the data or not. |
smartDashboard.putString(name, value, downsample)
This function is used to put a string in the SmartDashboard.
Downsample means to only keep the most recent data point. This is useful for real-time, but should be turned off for logs.
Kind: instance method of SmartDashboard
Param | Type | Default | Description |
---|---|---|---|
name | string |
The name of the string. | |
value | string |
The value of the string. | |
downsample | boolean |
true |
Whether to downsample the data or not. |
smartDashboard.flush()
This function is used to flush the SmartDashboard.
Every time a variable is updated, SmartDashboard will try to flush the data, but it will only flush if the period has passed.
So if variables are not updated frequently, some data may not be flushed. Use this function to force a flush.
A force flush does not respect the min period. A normal flush respects the min period, and can be called as frequently as you want.
Kind: instance method of SmartDashboard
MPI_Barrier() ⇒ Promise.<void>
MPI_Barrier is a synchronization function that blocks the processes until all processes have reached the barrier. This function is blocking, and it will only return after all the processes have reached the barrier.
If optimization flag is set, SSMR (Single Source Multiple Recipients) will be utilized where applicable.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when all the processes have reached the barrier.
MPI_Bcast(data_ptr, root) ⇒ Promise.<void>
MPI_Bcast broadcasts data from the root process to all other processes. This function is blocking, and it will only return after all the processes have received the data.
If optimization flag is set, SSMR (Single Source Multiple Recipients) will be utilized where applicable.
Another optimizatin made is sending parallel messages. If there is a lot of bcasts from the same gr_id, then the later ones don't need to wait for the earlier ones to propogate every other gr_id. The root can move on whenever it's done within the local gr. This parallelism maintains correctness and can offer up to 300x speedup.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the data has been broadcasted.
Param | Type | Description |
---|---|---|
data_ptr | Box |
The data to broadcast. |
root | number |
The root process ID. |
MPI_Ibcast(data_ptr, root)
MPI_Ibcast broadcasts data from the root process to all other processes. This function is non-blocking, and it will return immediately after the data has been broadcasted. The user can use the MPI_Request object to test if the broadcast is done, or to wait for the broadcast to be done.
If optimization flag is set, SSMR (Single Source Multiple Recipients) will be utilized where applicable.
Kind: global function
Param | Type | Description |
---|---|---|
data_ptr | Box |
The data to broadcast. |
root | number |
The root process ID that broadcasts the data. |
MPI_Gather(send_ptr, recv_ptr, root) ⇒ Promise.<void>
MPI_Gather is a collective operation that gathers data from all processes and stores it in the root process. All processes must provide the same count of data.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the gather is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The data to gather. |
recv_ptr | Box |
The box to store the gathered data. |
root | number |
The root process ID that gathers the data. |
MPI_Allgather(send_ptr, recv_ptr) ⇒ Promise.<void>
MPI_Allgather is a collective operation that gathers data from all processes and stores it in all processes. All processes must provide the same count of data.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the gather is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The data to gather. |
recv_ptr | Box |
The box to store the gathered data. |
MPI_Gatherv(send_ptr, recv_ptr, counts, offsets, root) ⇒ Promise.<void>
MPI_Gatherv is a collective operation that gathers data from all processes and stores it in the root process. Each process can provide a different count of data. This information must be provided.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the gather is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The data to gather. |
recv_ptr | Box |
The box to store the gathered data. |
counts | Array.<number> |
The count of data to gather from each process. |
offsets | Array.<number> |
The offset to store the data in the recv_ptr. |
root | number |
The root process ID that gathers the data. |
MPI_Allgatherv(send_ptr, recv_ptr, counts, offsets) ⇒ Promise.<void>
MPI_Allgatherv is a collective operation that gathers data from all processes and stores it in all processes. Each process can provide a different count of data. This information must be provided.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the gather is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The data to gather. |
recv_ptr | Box |
The box to store the gathered data. |
counts | Array.<number> |
The count of data to gather from each process. |
offsets | Array.<number> |
The offset to store the data in the recv_ptr. |
reschedule(callback)
This function is used to take a function off of the event queue and add it to the back of the event queue.
Sometimes, the main function is too long, and it blocks any message events from being processed. This function allows the main function to be paused and other events to be processed. After other queued events are processed, the main function is added back to the end of event queue to continue processing.
Kind: global function
Param | Type | Description |
---|---|---|
callback | function |
The function to pause and reschedule. |
flush_telemetry()
Sometimes the main function is too long and prevents the telemetry from being flushed. This function manually flushes the telemetry.
finish_setup()
This function is used to finish setting up this worker after the initial configuration is received.
on_init_message(event)
This function is used to receive a message from the main process in the initialization phase. After initialization is complete, this function is no longer used.
Kind: global function
Param | Type | Description |
---|---|---|
event | MessageEvent |
The message event from the main process. |
main(main_fn, worker_self)
The entry point for user code. The user supplies its main function, as well as the worker object itself.
This function sets up all the necessary components for the worker to run.
Kind: global function
Param | Type | Description |
---|---|---|
main_fn | function |
The main function of the user. |
worker_self | WorkerGlobalScope |
The worker object itself. |
MPI_Comm_rank(rank_ptr)
MPI function to obtain the rank of the current process.
Kind: global function
Param | Type | Description |
---|---|---|
rank_ptr | Box |
A box to store the rank of the current process. |
MPI_Comm_size(size_ptr)
MPI function to obtain the number of processes.
Kind: global function
Param | Type | Description |
---|---|---|
size_ptr | Box |
A box to store the number of processes. |
MPI_Init()
MPI function to initialize the MPI environment.
MPI_Finalize()
MPI function to finalize and finish the MPI environment.
box(data) ⇒ Box
Function to wrap data in a box.
Kind: global function
Returns: Box
- A box containing the data.
Param | Type | Description |
---|---|---|
data | any |
The data to wrap in a box. |
unbox(box) ⇒ any
Function to unbox data from a box.
Kind: global function
Returns: any
- The data from the box.
Param | Type | Description |
---|---|---|
box | Box |
The box containing the data. |
MPI_Test(request) ⇒ Promise.<boolean>
MPI_Test tests if the request is done. Regardless of whether the request is done or not, the callback should immediately return a boolean.
Kind: global function
Returns: Promise.<boolean>
- A promise that resolves when the test is done, indicating whether the request is done.
Param | Type | Description |
---|---|---|
request | MPI_Request |
The request to test. |
MPI_Wait(request) ⇒ Promise.<void>
MPI_Wait waits for the request to be done. The callback should return a promise that resolves when the request is done.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the request is done.
Param | Type | Description |
---|---|---|
request | MPI_Request |
The request to wait for. |
MPI_Send(data_ptr, dest_pid, start, count) ⇒ Promise.<void>
MPI_Send sends data to another process. This function is blocking, and it will only return after the receiver confirms that it has received the data.
start and count are optional parameters that allow the user to specify a slice of the array to send. Only use these parameters if the data is an array.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the data has been sent.
Param | Type | Description |
---|---|---|
data_ptr | Box |
The data to send. |
dest_pid | number |
The destination process ID. |
start | number |
The start index of the data to send. Default is 0 if only count is specified. |
count | number |
The number of elements to send. Only use if data is an array. |
MPI_Isend(data_ptr, dest_pid, start, count) ⇒ Promise.<MPI_Request>
MPI_Isend sends data to another process. This function is non-blocking, and it will return immediately after sending the data. The user can use the MPI_Request object to test if the buffer is ready to be reused.
start and count are optional parameters that allow the user to specify a slice of the array to send. Only use these parameters if the data is an array.
Kind: global function
Returns: Promise.<MPI_Request>
- A promise that indicates that the data has been sent.
Param | Type | Description |
---|---|---|
data_ptr | Box |
The data to send. |
dest_pid | number |
The destination process ID. |
start | number |
The start index of the data to send. Default is 0 if only count is specified. |
count | number |
The number of elements to send. Only use if data is an array. |
MPI_Recv(data_ptr, src_pid, start, count) ⇒ Promise.<void>
MPI_Recv receives data from another process. This function is blocking, and it will only return after the data has been received.
start and count are optional parameters that allow the user to specify a slice of the array to receive. Only use these parameters if the data is an array.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the data has been received.
Param | Type | Description |
---|---|---|
data_ptr | Box |
The box to store the received data. |
src_pid | number |
The source process ID. Default is null to receive from any process. |
start | number |
The start index of the data to receive. Default is 0 if only count is specified. |
count | number |
The number of elements to receive. Only use if data is an array. |
MPI_Irecv(data_ptr, src_pid, start, count) ⇒ Promise.<MPI_Request>
MPI_Irecv receives data from another process. This function is non-blocking, and it will return immediately after receiving the data. The user can use the MPI_Request object to test if the receive is done, or to wait for the receive to be done.
start and count are optional parameters that allow the user to specify a slice of the array to receive. Only use these parameters if the data is an array.
Kind: global function
Returns: Promise.<MPI_Request>
- A promise that indicates that the data has been received.
Param | Type | Description |
---|---|---|
data_ptr | Box |
The box to store the received data. |
src_pid | number |
The source process ID. Default is null to receive from any process. |
start | number |
The start index of the data to receive. Default is 0 if only count is specified. |
count | number |
The number of elements to receive. Only use if data is an array. |
MPI_Reduce(send_ptr, recv_ptr, operation) ⇒ Promise.<void>
MPI_Reduce is a collective operation that combines the data from all processes in the communicator and returns the result to a single process. The root process will receive the result.
The operation is function performed on the data pointed to by the data_ptr. The operation is defined by the operation parameter.
The optimized version does a local reduce and then send the local results to the root process for a final reduce in order to minimize communication bandwidth.
TODO: Future idea: If not a crossbar interconnect, try to reduce along the way.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when reduce is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The boxed data array to reduce. |
recv_ptr | Box |
The box to store the result array. |
operation | function |
The operation to perform on the data. |
MPI_Allreduce_local_optimized(send_ptr, recv_ptr, operation) ⇒ Promise.<void>
This function only performs a all_reduce operation in the local group of processes. It detects the type of interconnect and uses the appropriate strategy to perform the all_reduce operation most efficiently. The speedup is more significant when the array size is large.
Specifically, it uses the ring allreduce strategy for crossbar and ring interconnects, and the tree allreduce strategy for the tree interconnect.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when reduce is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The boxed data array to reduce. |
recv_ptr | Box |
The box to store the result array. |
operation | function |
The operation to perform on the data. |
MPI_Allreduce(send_ptr, recv_ptr, operation) ⇒ Promise.<void>
MPI_Allreduce is a collective operation that combines the data from all processes in the communicator and returns the result to all processes. The result is stored in the recv_ptr box.
If the optimized flag is set, and the operation is limited to the local group of processes, then the allreduce operation is performed using the optimized strategy depending on the interconnect type. If the operation spans multiple groups of processes, then the a local reduce is performed first, and a secondary reduce is performed between the groups to save bandwidth. This can have many times speedup when the array size or number of processors is large.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when reduce is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The boxed data array to reduce. |
recv_ptr | Box |
The box to store the result array. |
operation | function |
The operation to perform on the data. |
MPI_Scatter(send_ptr, recv_ptr, root) ⇒ Promise.<void>
MPI_Scatter is a collective operation that scatters data from the root process to all other processes. All processes must provide the same count of data.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the scatter is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The data to scatter. |
recv_ptr | Box |
The box to store the scattered data. |
root | number |
The root process ID that gathers the data. |
MPI_Scatterv(send_ptr, recv_ptr, root) ⇒ Promise.<void>
MPI_Scatterv is a collective operation that scatters data from the root process to all other processes. All processes must provide the same count of data.
Kind: global function
Returns: Promise.<void>
- A promise that resolves when the scatter is done.
Param | Type | Description |
---|---|---|
send_ptr | Box |
The data to scatter. |
recv_ptr | Box |
The box to store the scattered data. |
root | number |
The root process ID that gathers the data. |
partition(count, num_proc) ⇒ Object
This function partitions the work equally to the number of processors.
For example, if there is 6 work and 4 processors, the function will return [2, 2, 1, 1] and [0, 2, 4, 5].
Note that it will not return [2, 2, 2, 0] and [0, 2, 4, 6] because the work is not evenly distributed. The result will have difference of at most 1.
Kind: global function
Returns: Object
- The sizes and start indexes of the work.
Param | Type | Description |
---|---|---|
count | number |
The total number of work. |
num_proc | number |
The number of processors. |
make_wrap(n) ⇒ function
This function makes a wrap function that wraps the index around the array.
Kind: global function
Returns: function
- The wrap function that wraps the index around the array.
Param | Type | Description |
---|---|---|
n | number |
The size of the array. |
create_crossbar(num_nodes) ⇒ Object
This function creates channels between all pairs of workers. This function does not create the channels object, but rather pairs of ints that represent the workers that are connected.
This function also provides the routing table for each node, so they know where to send messages when they need to communicate with different nodes.
Kind: global function
Returns: Object
- The result routing computation
Param | Type | Description |
---|---|---|
num_nodes | number |
number of workers locally that needs to connect |
create_ring(num_nodes) ⇒ Object
This function creates channels between some pairs of workers. This function does not create the channels object, but rather pairs of ints that represent the workers that are connected.
The pattern being created is a ring structure.
This function also provides the routing table for each node, so they know where to send messages when they need to communicate with different nodes.
For example, if we have 4 workers, the following channels will be created:
0 <---> 1
1 <---> 2
2 <---> 3
3 <---> 0
For N workers, the number of channels created is O(N)
The longest path between any two workers is O(N)
Kind: global function
Returns: Object
- The result routing computation
Param | Type |
---|---|
num_nodes | number |
create_tree_pow_of_2(num_nodes) ⇒ Object
This function creates channels between some pairs of workers. This function does not create the channels object, but rather pairs of ints that represent the workers that are connected.
The pattern being created is a tree structure.
This function also provides the routing table for each node, so they know where to send messages when they need to communicate with different nodes.
Important note: This function only works when the number of workers is a power of 2.
For example, if we have 8 workers, the following channels will be created:
0 <---> 1
2 <---> 3
4 <---> 5
6 <---> 7
0 <---> 2
4 <---> 6
0 <---> 4
For N workers, the number of channels created is O(N)
The longest path between any two workers is O(log(N))
Kind: global function
Returns: Object
- The result routing computation
Param | Type | Description |
---|---|---|
num_nodes | number |
number of workers locally that needs to connect |
create_tree(num_nodes) ⇒ Object
This function creates channels between some pairs of workers. This function does not create the channels object, but rather pairs of ints that represent the workers that are connected.
The pattern being created is a tree structure.
This function also provides the routing table for each node, so they know where to send messages when they need to communicate with different nodes.
This function works for any number of workers, even if it is not a power of 2.
For example, if we have 7 workers, the following channels will be created:
0 <---> 1
2 <---> 3
4 <---> 5
0 <---> 2
4 <---> 6
0 <---> 4
For N workers, the number of channels created is O(N)
The longest path between any two workers is O(log(N))
Kind: global function
Returns: Object
- The result routing computation
Param | Type | Description |
---|---|---|
num_nodes | number |
number of workers locally that needs to connect |
Box : Object
A box holds data. This is used to pass data between functions by reference.
Config : Object
config
Key_A : any
Key_B : any
SmartDashboardType : 'pie'
| 'progress'
| 'graph'
| 'string'
Kind: global typedef