File: broadcast.py

package info (click to toggle)
rabit 0.0~git20200628.74bf00a-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 720 kB
  • sloc: cpp: 5,015; ansic: 710; python: 360; makefile: 306; sh: 136
file content (23 lines) | stat: -rwxr-xr-x 538 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python
"""
demo python script of rabit
"""
from __future__ import print_function
import os
import sys
# add path to wrapper
# for normal run without tracker script, add following line
# sys.path.append(os.path.dirname(__file__) + '/../wrapper')
import rabit

rabit.init()
n = 3
rank = rabit.get_rank()
s = None
if rank == 0:
    s = {'hello world':100, 2:3}
print('@node[%d] before-broadcast: s=\"%s\"' % (rank, str(s)))
s = rabit.broadcast(s, 0)

print('@node[%d] after-broadcast: s=\"%s\"' % (rank, str(s)))
rabit.finalize()