DasBetterR
jmh530
john.michael.hall at gmail.com
Tue Aug 1 13:42:53 UTC 2023
On Tuesday, 1 August 2023 at 12:37:58 UTC, jmh530 wrote:
> [snip]
>> - The custom allocator requires leaving 80 bits immediately
>> preceding the data free for R to store its metadata related to
>> the vector. There's no way around that as R would not know
>> what to do without the metadata.
>>
>> https://github.com/bachmeil/betterr/blob/main/testing/teststan.d
>
> [snip]
I'm a little confused by this
```d
// The 80 bits R needs
foreach(ii; 0..10) { y ~= 0.0; }
```
Isn't a double 64 bits? You're putting ten doubles here. That's
like 640 bits. I would think it only needs to have padding for a
real or two doubles (if x87 isn't available).
What about something like below? I'm not sure this works for you
or not (and I'm not really an expert on how align works, there
may be a better way to do this), but the idea would be do have
make the padded slice first on the D side and then transfer that
to R (I use a real if that is 80 bits, and two doubles otherwise).
```d
struct PaddedSlice(T)
{
align (1):
static if (real.mant_dig == 64) {
private real _metadata = 0;
} else {
private double[2] _metadata = [0, 0];
}
T[] data;
alias data this;
this(T[] x) {
data = x;
}
}
```
More information about the Digitalmars-d-announce
mailing list