Bug 16534 - R_allocLD not returning 16-byte-aligned storage blocks
Summary: R_allocLD not returning 16-byte-aligned storage blocks
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 3.2.1
Hardware: All All
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-09-15 16:41 UTC by Michael Sannella
Modified: 2015-09-15 16:41 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Sannella 2015-09-15 16:41:15 UTC
R 3.2.0 added a new Rapi entry R_allocLD, which was "guaranteed to
have sufficient alignment for long double pointers" (according to the
NEWS file).

While implementing this entry in TERR, I ran some test code with R,
and discovered that it was not returning 16-byte-aligned blocks.

Here is the test C code I used:
    for (int i = 1; i <= 5; i++)
    {
        long double* bb = R_allocLD(i);
        printf("R_allocLD(%d) == 0x%x\n", i, reinterpret_cast<size_t>(bb));
    }
    long double* cc = R_allocLD(100);
    printf("R_allocLD(100) == 0x%x\n", reinterpret_cast<size_t>(cc));

And here is what it prints for various versions of R on Windows and
Linux.  I would expect all of these addresses to end with the hex
digit "0", but they all end with hex digit "7" or "f".

R 3.2.0/Windows
    R_allocLD(1) == 0xb1e1407
    R_allocLD(2) == 0xb1d3bcf
    R_allocLD(3) == 0xb621f4f
    R_allocLD(4) == 0xb62208f
    R_allocLD(5) == 0xb6221ef
    R_allocLD(100) == 0xa1385a7
R 3.2.1/Windows
    R_allocLD(1) == 0xd1e7e6f
    R_allocLD(2) == 0xd1e7e07
    R_allocLD(3) == 0xd6d8a8f
    R_allocLD(4) == 0xd6d89e7
    R_allocLD(5) == 0xd6d892f
    R_allocLD(100) == 0xd5d886f
R 3.2.2/Windows
    R_allocLD(1) == 0xb1868a7
    R_allocLD(2) == 0xb186987
    R_allocLD(3) == 0xb610c0f
    R_allocLD(4) == 0xb610ca7
    R_allocLD(5) == 0xb5e1a0f
    R_allocLD(100) == 0xb6efd0f
R 3.2.0/Linux
    R_allocLD(1) == 0x1e20ac7
    R_allocLD(2) == 0x1e20a4f
    R_allocLD(3) == 0xc9e3e7
    R_allocLD(4) == 0xc4d94f
    R_allocLD(5) == 0xc4dd2f
    R_allocLD(100) == 0x1c760a7
R 3.2.1/Linux
    R_allocLD(1) == 0x1e79147
    R_allocLD(2) == 0x1e790cf
    R_allocLD(3) == 0xd7a507
    R_allocLD(4) == 0xd6eb2f
    R_allocLD(5) == 0xcd6d8f
    R_allocLD(100) == 0x1cd2ec7
R 3.2.2/Linux
    R_allocLD(1) == 0x2cc8c8f
    R_allocLD(2) == 0x2cc8c27
    R_allocLD(3) == 0x1a9ac8f
    R_allocLD(4) == 0x1a9b32f
    R_allocLD(5) == 0x1a6db8f
    R_allocLD(100) == 0x297cfe7