4747import types
4848from hashlib import md5
4949
50- from pyop2 .datatypes import IntType , as_cstr , _EntityMask , _MapMask
50+ from pyop2 .datatypes import IntType , as_cstr , _EntityMask , _MapMask , dtype_limits
5151from pyop2 .configuration import configuration
5252from pyop2 .caching import Cached , ObjectCached
5353from pyop2 .exceptions import *
@@ -473,7 +473,7 @@ def global_to_local_begin(self):
473473 assert self ._is_dat , "Doing halo exchanges only makes sense for Dats"
474474 assert not self ._in_flight , \
475475 "Halo exchange already in flight for Arg %s" % self
476- if self .access in [READ , RW , INC ]:
476+ if self .access in [READ , RW , INC , MIN , MAX ]:
477477 self ._in_flight = True
478478 self .data .global_to_local_begin (self .access )
479479
@@ -483,7 +483,7 @@ def global_to_local_end(self):
483483 Doing halo exchanges only makes sense for :class:`Dat` objects.
484484 """
485485 assert self ._is_dat , "Doing halo exchanges only makes sense for Dats"
486- if self .access in [READ , RW , INC ] and self ._in_flight :
486+ if self .access in [READ , RW , INC , MIN , MAX ] and self ._in_flight :
487487 self ._in_flight = False
488488 self .data .global_to_local_end (self .access )
489489
@@ -1647,7 +1647,7 @@ class Dat(DataCarrier, _EmptyDataMixin):
16471647 """
16481648
16491649 _globalcount = 0
1650- _modes = [READ , WRITE , RW , INC ]
1650+ _modes = [READ , WRITE , RW , INC , MIN , MAX ]
16511651
16521652 @validate_type (('dataset' , (DataCarrier , DataSet , Set ), DataSetTypeError ),
16531653 ('name' , str , NameTypeError ))
@@ -2121,6 +2121,9 @@ def global_to_local_begin(self, access_mode):
21212121 halo .global_to_local_begin (self , WRITE )
21222122 elif access_mode is INC :
21232123 self ._data [self .dataset .size :] = 0
2124+ elif access_mode in [MIN , MAX ]:
2125+ min_ , max_ = dtype_limits (self .dtype )
2126+ self ._data [self .dataset .size :] = {MAX : min_ , MIN : max_ }[access_mode ]
21242127
21252128 @collective
21262129 def global_to_local_end (self , access_mode ):
@@ -2134,7 +2137,7 @@ def global_to_local_end(self, access_mode):
21342137 if access_mode in [READ , RW ] and not self .halo_valid :
21352138 halo .global_to_local_end (self , WRITE )
21362139 self .halo_valid = True
2137- elif access_mode is INC :
2140+ elif access_mode in [ MIN , MAX , INC ] :
21382141 self .halo_valid = False
21392142
21402143 @collective
0 commit comments