Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Commit

Permalink
replace _update_ndarray_data_state_flags with set_donttouchdata
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Sep 1, 2024
1 parent 0d3e7d6 commit 1bef729
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ WriteMakefile(
LICENSE => 'perl',
MIN_PERL_VERSION => '5.14.0',
CONFIGURE_REQUIRES => {
PDL => '2.058', # trans_parent
PDL => '2.069', # nbytes method
'ExtUtils::MakeMaker' => '7.14',
},
PREREQ_PM => {
'PDL' => '2.058',
'PDL' => '2.069',
'threads::shared' => '1.21', # shared_clone
},
TEST_REQUIRES => {
Expand Down
14 changes: 5 additions & 9 deletions threads.pd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ BEGIN {
my %datasv_pointers :shared;
my %dim_arrays :shared;
my %types :shared;
my %nbytes :shared;
my %originating_tid :shared;
my %file_names :shared;

Expand Down Expand Up @@ -85,7 +86,7 @@ sub share_pdls {
. "name '$name' because $error");
}
_sv_refcount_inc($datasv_pointers{$name});
_update_ndarray_data_state_flags($to_store); # protect its memory
$to_store->set_donttouchdata; # protect its memory
if ($can_use_threads) {
$dim_arrays{$name} = shared_clone([$to_store->dims]);
$originating_tid{$name} = threads->tid;
Expand All @@ -94,6 +95,7 @@ sub share_pdls {
$dim_arrays{$name} = [$to_store->dims];
}
$types{$name} = $to_store->get_datatype;
$nbytes{$name} = $to_store->nbytes;
}
elsif (ref($to_store) eq '') {
# A file name, presumably; share via memory mapping
Expand Down Expand Up @@ -138,6 +140,7 @@ sub free_pdls {
delete $datasv_pointers{$name};
delete $dim_arrays{$name};
delete $types{$name};
delete $nbytes{$name};
delete $originating_tid{$name};
push @removed, $name;
}
Expand Down Expand Up @@ -186,7 +189,7 @@ sub retrieve_pdls {
_sv_refcount_inc($datasv_pointers{$name});
$new_ndarray->set_datatype($types{$name});
$new_ndarray->setdims(\@{$dim_arrays{$name}});
_update_ndarray_data_state_flags($new_ndarray); # protect its memory
$new_ndarray->set_donttouchdata($nbytes{$name}); # protect its memory
push @to_return, $new_ndarray;
}
elsif (exists $file_names{$name}) {
Expand Down Expand Up @@ -823,13 +826,6 @@ _new_ndarray_around(datasv_pointer)
OUTPUT:
RETVAL

void
_update_ndarray_data_state_flags (p)
pdl * p
CODE:
/* Tell the ndarray that it doesn't really own the data... */
p->state |= PDL_DONTTOUCHDATA | PDL_ALLOCATED;

void
_sv_refcount_inc(sv_pointer)
size_t sv_pointer
Expand Down

0 comments on commit 1bef729

Please sign in to comment.