Skip to content

Commit fe582e1

Browse files
author
Ritvik Rao
committed
Merge remote-tracking branch 'origin/main' into ritvik/ray_and_mac_test
2 parents 4f49604 + a460a95 commit fe582e1

File tree

7 files changed

+23
-14
lines changed

7 files changed

+23
-14
lines changed

auto_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def searchForPython(python_implementations):
3030

3131

3232
# ----------------------------------------------------------------------------------
33-
TIMEOUT = 60 # timeout for each test (in seconds)
33+
TIMEOUT = 120 # timeout for each test (in seconds)
3434
CHARM_QUIET_AFTER_NUM_TESTS = 5
3535

3636
commonArgs = ['++local']

charm4py/c_object_store.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ cdef class CObjectStore:
224224
cpdef void request_location_object(self, ObjectId obj_id, int requesting_pe):
225225
# this function is intended to be called on home pes of the object id
226226
cdef object obj = self.lookup_object(obj_id)
227-
if obj != None:
227+
if not (obj is None):
228228
self.proxy[requesting_pe].receive_remote_object(obj_id, obj)
229229
return
230230
cdef int pe = self.lookup_location(obj_id, fetch=False)
@@ -248,7 +248,7 @@ cdef class CObjectStore:
248248

249249
cpdef void request_object(self, ObjectId obj_id, int requesting_pe):
250250
cdef object obj = self.lookup_object(obj_id)
251-
if obj == None:
251+
if obj is None:
252252
self.buffer_obj_request(obj_id, requesting_pe)
253253
else:
254254
self.proxy[requesting_pe].receive_remote_object(obj_id, obj)

charm4py/charm.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ def __init__(self):
156156
self.threadMgr = threads.EntryMethodThreadManager(self)
157157
self.createFuture = self.Future = self.threadMgr.createFuture
158158

159+
# The send buffer is not currently used since we do not buffer messages on
160+
# the sender. This should be used later when scheduling decisions are to be
161+
# based on locations of arguments
159162
self.send_buffer = MessageBuffer()
160163
self.receive_buffer = MessageBuffer()
161164
# TODO: maybe implement this buffer in c++
@@ -182,7 +185,7 @@ def print_dbg(self, *args, **kwargs):
182185
def get_future_value(self, fut):
183186
#self.print_dbg("Getting data for object", fut.id)
184187
obj = fut.lookup_object()
185-
if obj == None:
188+
if obj is None:
186189
local_f = LocalFuture()
187190
self.future_get_buffer[fut.store_id] = (local_f, fut)
188191
fut.request_object()
@@ -370,11 +373,11 @@ def recvArrayMsg(self, aid, index, ep, msg, dcopy_start):
370373
for i, arg in enumerate(args[:-1]):
371374
if isinstance(arg, Future):
372375
dep_obj = arg.lookup_object()
373-
if dep_obj != None:
374-
args[i] = dep_obj
375-
else:
376+
if dep_obj is None:
376377
dep_ids.append(arg.store_id)
377378
arg.request_object()
379+
else:
380+
args[i] = dep_obj
378381
if len(dep_ids) > 0:
379382
charm.receive_buffer.insert(dep_ids, (obj, ep, header, args))
380383
else:

charm4py/entry_method.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _run(self, obj, header, args, ret_fut=False):
4747
fut = args[-1]
4848
args = args[:-1]
4949
ret = getattr(obj, self.name)(*args)
50-
if ret_fut and ret != None:
50+
if ret_fut and not (ret is None):
5151
fut.create_object(ret)
5252
except SystemExit:
5353
exit_code = sys.exc_info()[1].code

charm4py/threads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def is_local(self):
136136
if not self.store:
137137
raise ValueError("Operation not supported for future not"
138138
" stored in the object store")
139-
return self.lookup_object() != None
139+
return not (self.lookup_object() is None)
140140

141141
def create_object(self, obj):
142142
from .charm import charm

examples/ray/parameter_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def compute_gradients(self, weights):
125125
def sync_train(args):
126126
ray.init()
127127

128-
iterations = 101
128+
iterations = 11
129129
num_workers = 4
130130

131131
model = ConvNet()
@@ -159,7 +159,7 @@ def async_train(args):
159159

160160
model = ConvNet()
161161
test_loader = get_data_loader()[1]
162-
iterations = 101
162+
iterations = 11
163163
num_workers = 4
164164

165165
print("Running asynchronous parameter server training.")

examples/ray/simple.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from charm4py import charm, coro, Chare, Array, ray
22
from time import sleep
3+
import numpy as np
34

45

56
@ray.remote
@@ -26,14 +27,19 @@ def main(args):
2627
ray.init()
2728
# create 3 instances of MyChare, distributed among cores by the runtime
2829
arr = [Compute.remote(i) for i in range(4)]
29-
30+
31+
obj1 = np.arange(100)
32+
obj2 = np.arange(100)
33+
a = ray.put(obj1)
34+
b = ray.put(obj2)
3035
c = arr[0].add.remote(1, 2) # fut id 0
3136
d = arr[1].add.remote(3, c) # fut id 1
3237
e = arr[2].add.remote(2, d)
3338
f = arr[3].add.remote(c, 4)
34-
g = add_task.remote(e, f)
39+
g = arr[3].add.remote(a, b)
40+
h = add_task.remote(e, f)
3541

36-
not_ready = [c, d, e, f, g]
42+
not_ready = [c, d, e, f, g, h]
3743
while len(not_ready) > 0:
3844
ready, not_ready = ray.wait(not_ready)
3945
print("Fetched value: ", ray.get(ready))

0 commit comments

Comments
 (0)