Skip to content

Commit

Permalink
Implement high rank indexing for devices
Browse files Browse the repository at this point in the history
  • Loading branch information
arcfide committed Dec 1, 2023
1 parent eabf12d commit bac4cf3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
39 changes: 37 additions & 2 deletions rtm/ibeams.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ index_func(struct cell_array **z,
asp[j] = sp[i];

if (idx[i]->type != ARR_SPAN) {
CHKAF(af_cast(&v, idx[i]->values, s64), dev4_fail);
CHKAF(af_cast(&v, idx[i]->values, u64), dev4_fail);
CHKAF(af_set_array_indexer(ix, v, j), dev4_fail);
}
}
Expand Down Expand Up @@ -1132,7 +1132,42 @@ index_func(struct cell_array **z,
}

if (arr->storage == STG_DEVICE) {
CHK(16, fail, L"High rank device indexing not supported yet.");
af_index_t *ix;
af_array t, v;
dim_t asp[3];

t = NULL;
v = NULL;
asp[0] = array_count(r);
asp[1] = 1;
asp[2] = 1;
arr->values = r->values;

CHKAF(af_create_indexers(&ix), fail);

for (size_t i = 0; i < ic; i++) {
asp[1] = sp[i];
asp[0] /= sp[i];

CHKAF(af_cast(&v, idx[i]->values, u64), devhr_fail);
CHKAF(af_set_array_indexer(ix, v, 1), devhr_fail);
CHKAF(af_moddims(&t, arr->values, 3, asp), devhr_fail);
CHKAF(af_index_gen(&arr->values, t, 3, ix), devhr_fail);
CHKAF(af_release_array(t), devhr_fail);t = NULL;
CHKAF(af_release_array(v), devhr_fail);v = NULL;

asp[2] *= cnt[i];
}

t = arr->values;
CHKAF(af_flat(&arr->values, t), devhr_fail);

devhr_fail:
af_release_array(v);
af_release_array(t);
af_release_indexers(ix);

goto done;
}

if (arr->storage != STG_HOST)
Expand Down
1 change: 1 addition & 0 deletions tests/t0064_index_tests.dyalog
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ I8←{⍬≡⍴⍵:⍵ ⋄ ⊃((⎕DR ⍵)83)⎕DR ⍵}
∆index∆16_TEST'index∆R1' MK∆T2 (9 5) (?10 61000)
∆index∆17_TEST'index∆R1' MK∆T2 (9 5) (?100 20 51000)
∆index∆18_TEST'index∆R1' MK∆T2 (9 5) (?100 20 51000)
∆index∆19_TEST'index∆R1' MK∆T2 ((9 5) 5 2 2 1) (?100 20 5 3 4 51000)

∆∆∆_TEST{#.UT.expect,¨0 0 _#.⎕EX¨cn tn #.⎕NC¨cn tn}

Expand Down

0 comments on commit bac4cf3

Please sign in to comment.