Sunday, January 10, 2021

Digest for comp.lang.c++@googlegroups.com - 8 updates in 4 topics

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jan 10 01:37PM -0800

On 1/8/2021 5:49 PM, Chris M. Thomasson wrote:
 
> Any advise?
 
> Here is the code:
> __________________________________
[...]
 
So far, I see a couple of places where I failed to add in a std:: in
some math functions during the port. fabs, log10, cos and sin.
 
ct_circle
ct_plane_init
ct_canvas_log_density_post_processing
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jan 09 10:32PM -0800

On 1/9/2021 10:01 PM, Bonita Montero wrote:
 
>>> The newed memory would be aligned also.
 
>> Really? ...
 
> Yes.
 
Show me.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jan 09 10:34PM -0800

On 1/9/2021 10:01 PM, Bonita Montero wrote:
 
>>> The newed memory would be aligned also.
 
>> Really? ...
 
> Yes.
 
You cut off my point about using new vs aligned_alloc and placement new.
Bonita Montero <Bonita.Montero@gmail.com>: Jan 10 09:31AM +0100


>>> Really? ...
 
>> Yes.
 
> Show me.
 
#include <iostream>
#include <atomic>
#include <cstdint>
#include <memory>
#include <vector>
 
using namespace std;
 
struct alignas(hardware_constructive_interference_size) A
{
atomic<uint64_t> valaue;
} a;
 
int main()
{
vector<unique_ptr<A>> vua( 1'000'000 );
for( unique_ptr<A> &ua : vua )
ua = make_unique<A>();
bool fits = true;
for( unique_ptr<A> &ua : vua )
if( (uintptr_t)ua.get() % 64 )
fits = false;
cout << (fits ? "fits" : "doesn't fit") << endl;
}
Bonita Montero <Bonita.Montero@gmail.com>: Jan 10 10:00AM +0100

Now, that's a version with my own semaphore-class:
 
#if defined(_MSC_VER)
#include <Windows.h>
#elif defined(__unix__)
#include <unistd.h>
#include <sched.h>
#include <sys/resource.h>
#include <sys/types.h>

No comments: