Module Import alias Import alias identifier ImportFrom alias ImportFrom alias Assign NameStore Num FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Str decorator_list Call AttributeLoad NameLoad attr keyword ListLoad TupleLoad NameLoad NameLoad NameLoad NameLoad TupleLoad Num NameLoad NameLoad NameLoad TupleLoad BinOpDiv NameLoad Num NameLoad NameLoad NameLoad TupleLoad Num BinOpDiv NameLoad Num NameLoad NameLoad FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad Num Str decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad Num Str decorator_list AttributeLoad NameLoad attr FunctionDef arguments args defaults body Return Call AttributeLoad NameLoad attr Call NameLoad NameLoad keyword AttributeLoad NameLoad attr decorator_list ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad Call NameLoad AttributeLoad NameLoad attr Str decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad ListLoad Call NameLoad Call NameLoad AttributeLoad NameLoad attr Str decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr Num Num AttributeLoad NameLoad attr Str decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr Num Num AttributeLoad NameLoad attr Str decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad ListLoad Call NameLoad Call NameLoad AttributeLoad NameLoad attr Str keyword NameLoad decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Assert Call NameLoad Call NameLoad Lambda arguments args NameParam defaults CompareEq NameLoad Num AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str With Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assert CompareEq Call NameLoad AttributeLoad NameLoad attr BinOpDiv BinOpMult NameLoad BinOpAdd NameLoad Num Num If CompareEq NameLoad NameLoad body Assert CompareEq Call NameLoad AttributeLoad NameLoad attr BinOpDiv BinOpMult NameLoad BinOpAdd NameLoad Num Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num BinOpDiv BinOpMult NameLoad BinOpAdd NameLoad Num Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign SubscriptStore AttributeLoad NameLoad attr Index Num Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num BinOpAdd AttributeLoad NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Str Assign SubscriptStore AttributeLoad NameLoad attr Index Num BinOpMult NameLoad Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num BinOpMult NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Str Assign SubscriptStore AttributeLoad NameLoad attr Index Num Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Str Assign SubscriptStore AttributeLoad NameLoad attr Index Num Num Assign SubscriptStore AttributeLoad NameLoad attr Slice Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assert CompareEq Call NameLoad AttributeLoad NameLoad attr BinOpDiv BinOpMult NameLoad BinOpAdd NameLoad Num Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Assert Call NameLoad Call NameLoad Lambda arguments args NameParam defaults Call NameLoad CompareEq NameLoad ListLoad Num Num AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Assert BoolOpAnd Call NameLoad CompareEq SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Index Num Num Call NameLoad CompareEq SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Index Num Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assert SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Assert SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign NameStore AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Call NameLoad ListLoad NameLoad Call NameLoad With Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad body Assign SubscriptStore NameLoad Index Num Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign SubscriptStore AttributeLoad NameLoad attr Slice Num Assign SubscriptStore AttributeLoad NameLoad attr Slice Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Slice Num Assign SubscriptStore AttributeLoad NameLoad attr Slice Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num BinOpMult Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign SubscriptStore AttributeLoad NameLoad attr Slice Num Assert Call AttributeLoad CompareEq AttributeLoad NameLoad attr Num attr Expr Call AttributeLoad NameLoad attr Assert Call AttributeLoad CompareEq AttributeLoad NameLoad attr Num attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign SubscriptStore AttributeLoad NameLoad attr Slice Num Assert Call AttributeLoad CompareEq AttributeLoad NameLoad attr Num attr Expr Call AttributeLoad NameLoad attr Assert Call AttributeLoad CompareEq AttributeLoad NameLoad attr Num attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Slice Num Assign NameStore Call AttributeLoad NameLoad attr Str Str keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad AttributeLoad NameLoad attr Assert Call AttributeLoad CompareEq AttributeLoad NameLoad attr Num attr decorator_list decorator_list If CompareEq NameLoad Str body Import alias Expr Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad
N/A N/A pytest N/A numpy np pyop2 op2 pyop2.exceptions MapValueError N/A nelems 4096 elems N/A N/A request N/A N/A N/A N/A N/A op2 Set N/A request param elems N/A N/A N/A pytest fixture params N/A N/A nelems nelems nelems nelems N/A 0 nelems nelems nelems N/A N/A nelems 2 nelems nelems nelems N/A 0 N/A nelems 2 nelems nelems delems N/A N/A elems N/A N/A N/A N/A N/A op2 DataSet elems 1 delems N/A N/A pytest fixture delems2 N/A N/A elems N/A N/A N/A N/A N/A op2 DataSet elems 2 delems2 N/A N/A pytest fixture xarray N/A N/A N/A N/A N/A N/A N/A np array N/A range nelems dtype N/A np uint32 N/A TestDirectLoop N/A N/A N/A 
    Direct Loop Tests
     x N/A N/A cls delems N/A N/A N/A N/A N/A op2 Dat delems N/A xarray N/A np uint32 x N/A N/A pytest fixture y N/A N/A cls delems2 N/A N/A N/A N/A N/A op2 Dat delems2 N/A N/A xarray N/A xarray N/A np uint32 x N/A N/A pytest fixture g N/A N/A cls N/A N/A N/A N/A N/A op2 Global 1 0 N/A np uint32 g N/A N/A pytest fixture h N/A N/A cls N/A N/A N/A N/A N/A op2 Global 1 1 N/A np uint32 h N/A N/A pytest fixture soa N/A N/A cls delems2 N/A N/A N/A N/A N/A op2 Dat delems2 N/A N/A xarray N/A xarray N/A np uint32 x soa True N/A N/A pytest fixture test_wo N/A N/A self backend elems x N/A N/A N/A Set a Dat to a scalar value with op2.WRITE. N/A kernel_wo void kernel_wo(unsigned int* x) { *x = 42; } N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel_wo kernel_wo elems N/A x N/A op2 WRITE N/A N/A all N/A map N/A N/A N/A x N/A N/A x 42 N/A x data N/A test_mismatch_set_raises_error N/A N/A self backend elems x N/A N/A N/A The iterset of the parloop should match the dataset of the direct dat. N/A kernel_wo void kernel_wo(unsigned int* x) { *x = 42; } N/A N/A N/A pytest raises MapValueError N/A N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel_wo kernel_wo N/A N/A op2 Set N/A elems size N/A x N/A op2 WRITE N/A test_rw N/A N/A self backend elems x N/A N/A N/A Increment each value of a Dat by one with op2.RW. N/A kernel_rw void kernel_rw(unsigned int* x) { (*x) = (*x) + 1; } N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel_rw kernel_rw elems N/A x N/A op2 RW N/A _nelems N/A elems size N/A N/A N/A sum N/A x data_ro N/A N/A _nelems N/A _nelems 1 2 N/A N/A _nelems nelems N/A N/A N/A N/A sum N/A x data_ro_with_halos N/A N/A nelems N/A nelems 1 2 N/A test_global_inc N/A N/A self backend elems x g N/A N/A N/A Increment each value of a Dat by one and a Global at the same time. N/A kernel_global_inc void kernel_global_inc(unsigned int* x, unsigned int* inc) {
          (*x) = (*x) + 1; (*inc) += (*x);
        } N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel_global_inc kernel_global_inc elems N/A x N/A op2 RW N/A g N/A op2 INC N/A _nelems N/A elems size N/A N/A N/A N/A g data N/A 0 N/A N/A _nelems N/A _nelems 1 2 N/A test_global_inc_init_not_zero N/A N/A self backend elems g N/A N/A N/A Increment a global initialized with a non-zero value. N/A k void k(unsigned int* inc) { (*inc) += 1; } N/A N/A N/A g data N/A 0 10 N/A N/A N/A op2 par_loop N/A N/A op2 Kernel k k elems N/A g N/A op2 INC N/A N/A N/A N/A g data N/A 0 N/A N/A elems size 10 N/A test_global_max_dat_is_max N/A N/A self backend elems x g N/A N/A N/A Verify that op2.MAX reduces to the maximum value. N/A k_code void k(unsigned int *x, unsigned int *g) {
          if ( *g < *x ) { *g = *x; }
        } N/A k N/A N/A op2 Kernel k_code k N/A N/A N/A op2 par_loop k elems N/A x N/A op2 READ N/A g N/A op2 MAX N/A N/A N/A N/A g data N/A 0 N/A N/A N/A x data max N/A test_global_max_g_is_max N/A N/A self backend elems x g N/A N/A N/A Verify that op2.MAX does not reduce a maximum value smaller than the
        Global's initial value. N/A k_code void k(unsigned int *x, unsigned int *g) {
          if ( *g < *x ) { *g = *x; }
        } N/A k N/A N/A op2 Kernel k_code k N/A N/A N/A g data N/A 0 N/A nelems 2 N/A N/A N/A op2 par_loop k elems N/A x N/A op2 READ N/A g N/A op2 MAX N/A N/A N/A N/A g data N/A 0 N/A nelems 2 N/A test_global_min_dat_is_min N/A N/A self backend elems x g N/A N/A N/A Verify that op2.MIN reduces to the minimum value. N/A k_code void k(unsigned int *x, unsigned int *g) {
          if ( *g > *x ) { *g = *x; }
        } N/A k N/A N/A op2 Kernel k_code k N/A N/A N/A g data N/A 0 1000 N/A N/A N/A op2 par_loop k elems N/A x N/A op2 READ N/A g N/A op2 MIN N/A N/A N/A N/A g data N/A 0 N/A N/A N/A x data min N/A test_global_min_g_is_min N/A N/A self backend elems x g N/A N/A N/A Verify that op2.MIN does not reduce a minimum value larger than the
        Global's initial value. N/A k_code void k(unsigned int *x, unsigned int *g) {
          if ( *g > *x ) { *g = *x; }
        } N/A k N/A N/A op2 Kernel k_code k N/A N/A N/A g data N/A 0 10 N/A N/A N/A x data N/A 11 N/A N/A N/A op2 par_loop k elems N/A x N/A op2 READ N/A g N/A op2 MIN N/A N/A N/A N/A g data N/A 0 10 N/A test_global_read N/A N/A self backend elems x h N/A N/A N/A Increment each value of a Dat by the value of a Global. N/A kernel_global_read 
        void kernel_global_read(unsigned int* x, unsigned int* h) {
          (*x) += (*h);
        } N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel_global_read kernel_global_read elems N/A x N/A op2 RW N/A h N/A op2 READ N/A _nelems N/A elems size N/A N/A N/A sum N/A x data_ro N/A N/A _nelems N/A _nelems 1 2 N/A test_2d_dat N/A N/A self backend elems y N/A N/A N/A Set both components of a vector-valued Dat to a scalar value. N/A kernel_2d_wo void kernel_2d_wo(unsigned int* x) {
          x[0] = 42; x[1] = 43;
        } N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel_2d_wo kernel_2d_wo elems N/A y N/A op2 WRITE N/A N/A all N/A map N/A N/A N/A x N/A N/A all N/A x N/A 42 43 N/A y data N/A test_2d_dat_soa N/A N/A self backend elems soa N/A N/A N/A Set both components of a vector-valued Dat in SoA order to a scalar
        value. N/A kernel_soa void kernel_soa(unsigned int * x) {
          OP2_STRIDE(x, 0) = 42; OP2_STRIDE(x, 1) = 43;
        } N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel_soa kernel_soa elems N/A soa N/A op2 WRITE N/A N/A N/A all N/A N/A N/A soa data N/A N/A N/A 0 42 N/A all N/A N/A N/A soa data N/A N/A N/A 1 43 N/A test_soa_should_stay_c_contigous N/A N/A self backend elems soa N/A N/A N/A Verify that a Dat in SoA order remains C contiguous after being
        written to in a par_loop. N/A k void dummy(unsigned int *x) {} N/A N/A N/A N/A soa data flags N/A C_CONTIGUOUS N/A N/A N/A op2 par_loop N/A N/A op2 Kernel k dummy elems N/A soa N/A op2 WRITE N/A N/A N/A N/A soa data flags N/A C_CONTIGUOUS N/A test_parloop_should_set_ro_flag N/A N/A self backend elems x N/A N/A N/A Assert that a par_loop locks each Dat argument for writing. N/A kernel void k(unsigned int *x) { *x = 1; } N/A x_data N/A x data_with_halos N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel k elems N/A x N/A op2 WRITE N/A N/A N/A N/A N/A op2 base _trace evaluate N/A set N/A x N/A set N/A N/A N/A pytest raises N/A RuntimeError ValueError N/A N/A N/A x_data N/A 0 1 N/A test_host_write N/A N/A self backend elems x g N/A N/A N/A Increment a global by the values of a Dat. N/A kernel void k(unsigned int *x, unsigned int *g) { *g += *x; } N/A N/A N/A x data N/A 1 N/A N/A N/A g data N/A 0 N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel k elems N/A x N/A op2 READ N/A g N/A op2 INC N/A _nelems N/A elems size N/A N/A N/A N/A g data N/A 0 _nelems N/A N/A N/A x data N/A 2 N/A N/A N/A g data N/A 0 N/A N/A N/A op2 par_loop N/A N/A op2 Kernel kernel k elems N/A x N/A op2 READ N/A g N/A op2 INC N/A N/A N/A N/A g data N/A 0 N/A 2 _nelems N/A test_zero_1d_dat N/A N/A self backend x N/A N/A N/A Zero a Dat. N/A N/A N/A x data N/A 10 N/A N/A N/A N/A N/A x data 10 all N/A N/A N/A x zero N/A N/A N/A N/A N/A x data 0 all N/A test_zero_2d_dat N/A N/A self backend y N/A N/A N/A Zero a vector-valued Dat. N/A N/A N/A y data N/A 10 N/A N/A N/A N/A N/A y data 10 all N/A N/A N/A y zero N/A N/A N/A N/A N/A y data 0 all N/A test_kernel_cplusplus N/A N/A self backend delems N/A N/A N/A Test that passing cpp=True to a Kernel works. N/A y N/A N/A op2 Dat delems dtype N/A np float64 N/A N/A N/A y data N/A -10.5 N/A k N/A N/A op2 Kernel 
        #include <cmath>

        void kernel(double *y)
        {
            *y = std::abs(*y);
        }
         kernel cpp True N/A N/A N/A op2 par_loop k N/A N/A y dataset set N/A y N/A op2 RW N/A N/A N/A N/A N/A y data 10.5 all N/A N/A N/A N/A __name__ __main__ N/A N/A os N/A N/A N/A pytest main N/A N/A N/A os path abspath __file__