220 38131 <CAFdMc-0wber+dL_ugAcg7OBxLoajOOU8mMqLmS-aKTWHRcCghQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "dgutson ." <danielgutson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: memcpy/memset/etc overloads for volatile memory
Date: Fri, 18 May 2018 22:24:37 -0300
Lines: 153
Approved: news@gmane.org
Message-ID: <CAFdMc-0wber+dL_ugAcg7OBxLoajOOU8mMqLmS-aKTWHRcCghQ@mail.gmail.com>
References: <CAFdMc-0NAvWrkwzpgEKq4DQj=0vL_0F2s17XyR9MSUNJk5R0sw@mail.gmail.com>
 <CAFdMc-3V0VJ9nOs2fg4OuRr4N8TG-VXsrek1v=CJpr=Bqt98+Q@mail.gmail.com>
 <dc37b3f7-74b8-b94f-0a1c-59bb99ecbccc@gmail.com> <2300193.1RphyUdPvq@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="0000000000005fecf4056c84ef4a"
X-Trace: blaine.gmane.org 1526692971 26178 195.159.176.226 (19 May 2018 01:22:51 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 19 May 2018 01:22:51 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDE3NBMV6UFBBY7Z7XLQKGQETY6SXCY@isocpp.org Sat May 19 03:22:47 2018
Return-path: <std-proposals+bncBDE3NBMV6UFBBY7Z7XLQKGQETY6SXCY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f200.google.com ([209.85.220.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDE3NBMV6UFBBY7Z7XLQKGQETY6SXCY@isocpp.org>)
	id 1fJqa2-0006bM-0x
	for gclcip-std-proposals@m.gmane.org; Sat, 19 May 2018 03:22:42 +0200
Original-Received: by mail-qk0-f200.google.com with SMTP id f19-v6sf514404qkm.23
        for <gclcip-std-proposals@m.gmane.org>; Fri, 18 May 2018 18:24:53 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1526693092; cv=pass;
        d=google.com; s=arc-20160816;
        b=XLOYcWGQzu1dR5zxqfm52zHTwen79aaB6XMbm1Y3aPpQ4Oo9fU+WBQpAunK+99gmnV
         LBNSBIsBybw7MgmsqkjZ3iceGmFdm8dJfczg/VlVP1RqO0N0Xf866i5OGJGMrKzE4G/J
         ENBlcwtmpuTAT/9LeYt3o/eNepRMKMpGuj8QGf5IX3kwVbZP+hFEBUdcmnrnrxSWjgFN
         H57Sqwt3X7gmNvO5trS347FopqEA+vfdMGm20tOn3ZP6nPSx0bZSSALy5ljdIyEiYJWk
         rIzC+YE9daYwH06tHIKtwafZmOW4lPlTde5iPPggGd1r8nx+gHXeDrNNX2p5kf4wY0aQ
         loGg==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:in-reply-to:references:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=UyKJAjzcLyRxm/ORc3PbOcYDn5v83jKEotjF5JNrBMo=;
        b=GRu/tyTgtlOxvcQFZyfJU6/soS3bzmgaviiIjJTeuhgoId7GLKzXQJJIwdnLFysXub
         hIXw6Dog7p9YEY227iZYkVWdf4ZLBou980lbe9Z6CtwZX/DnBDtRzRC7nWnot5WTo6yx
         ZdJJLkPVxLDBPQo9RZfQ7SULJpuVZcze6ftUqRIX8qmxFRAmTl7AfaDUynuQ/ZQ35ssZ
         Di4Dy3xtRoJ5X2sPWMf9yIx8XqckB+yQ1RHGUHv/Tlv3NTgC/iKTmVECNMzp5aWsc/5F
         r2J41UrHZ1zRmf+dzdlr1XpOPUW8GXamDRAxLEK0PtCTzRlmqgNzizP6slbG1aPn+Vtr
         Pyzw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=RbM641x1;
       spf=pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=danielgutson@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=UyKJAjzcLyRxm/ORc3PbOcYDn5v83jKEotjF5JNrBMo=;
        b=Rkj9BfHtWgRMubY8NCwP0M4pLyXDNFKYRz7KZwjQ5XewEEClWKPjlNTPcv0ZQHRWbn
         WhcRyL3edc705SoKnjIeu5Avv3Y4rS92duD0xuSvdhg6mqNlEn8NV0zPeJ9op7tP2hTI
         x4fxCKL2Y0sR4RON8izdSoxbrA3ZVZFlAdHalJO6INFB3lngFKjfBs3+ceiI1ySXmXPO
         GQaLkb444ayvIK/TERWtdWRH8uq3jQFO3lNZ+qlHUmb6Jewb0UMfYtpzXsJjl1PxRL6h
         qT6DoS387mmJJvtipBvACp6AmHBJflork6dRWkbRJbg60tSK8JGMpxk3+74TXSX5EhEs
         o8ew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=UyKJAjzcLyRxm/ORc3PbOcYDn5v83jKEotjF5JNrBMo=;
        b=Z1CCbQAW9mbNKfeV/0Xr9mUtDA8jXirXOmWVOR8SIdVz1JsTGg7XMCkxnLJM8WCFjQ
         IEdXpFfsRPwZ2AC773Al/KUVggorm94gXnD+xvyxXp8GhTok1tVnK0Whjt/alneSuPgT
         +y/1/y6MpR1YwgzNd3eXiiZvWlaOVRKPdqplrjwksqi5LUjuT+9HSuQxjQyv1kZ/fpHS
         1XhbEjd3pfolrmtC1fwTHpjN93YqF8Owt+SIhtcHRpXyslSuhzN/IlJuYMO66JKGvYfY
         xX/aBXKYKYqTZmZocsy7Iz657g9qawqoclbMBu8uNtAPUOWLMm027aLmEInkoWjzTn6+
         oNlQ==
X-Gm-Message-State: ALKqPwfgtf7G2/dlUmdx0RBDoMxW0uXFxqgtYJPZj9N25AUNSttWLFN3
	URc7baqdUvPkLGylxlkif9dkBw==
X-Google-Smtp-Source: AB8JxZopK3D5jZlHqlsyskkNMRZQmjwRwuCgW5VTNp6RQSsKP1Nq0QmrN2WiF7KzNAdlr59gFqBZww==
X-Received: by 2002:ac8:7298:: with SMTP id v24-v6mr7677275qto.3.1526693092854;
        Fri, 18 May 2018 18:24:52 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:ac8:72c3:: with SMTP id o3-v6ls4860672qtp.5.gmail; Fri, 18
 May 2018 18:24:51 -0700 (PDT)
X-Received: by 2002:ac8:302a:: with SMTP id f39-v6mr11910148qte.257.1526693091663;
        Fri, 18 May 2018 18:24:51 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1526693091; cv=none;
        d=google.com; s=arc-20160816;
        b=K/jCOdz8yUG2VOMxt35DcTeRSkZTrhg6NFAjLLIWwSx5N1RePtKDPMhz7mXfTvA8Gt
         YuXP00p7NZSSK5+w2FjqLcfpVag4Cy7uCc2tYJRZ0/ozcjmwbW64RXz9C1vuDF6kdx1u
         V6GNIjbrDGGLu02KKCOO/GFEqdSPiXrYJ1q2mxzfHZJrp8uLS+ETvxW9/Cb4Eq4auLXE
         CLliULo2onQRV8iSt5cK4yivNyItjAZs7UZURtzN1Wu4P5t8Rt6tHcIK8dSAG+4EKNNp
         +lMtn3faIeTMejioYPFkD6S3w+sEq941XLTBSqzcLA38lXdjsN5+btyw4mherbGA1Nlg
         ewyw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature:arc-authentication-results;
        bh=LojjpsSJ2Y7ttgIW/v9NFYpdCM2nW0+Y4iatpoUC370=;
        b=BhHis+5BV7U9lJcLtwlX0zVbgrCTZ2b4xdUeC+VMjuM0PNikF2RTCGngrZG9/4lz4z
         9qdGOtHMYJAOdyuiI58+gtJPfRA47e2rCcQsZEmj7J4hiQ12sBo65owWML+BsfycZYeL
         O+VHuYq4WO/IJU8KLIIxkppKcGgPAHwpGStuzGq+3MFPeDeJPHRX/uZcOBLYlwUsuEWs
         Dlm1XIR7AgkrlgWXrvwh4/EW2mYWXHVrXnwl0m0V6Lf1WDDA7H+DGvd5jbS7zgpExWAf
         CZpsi0MJ0QRtX0GwqTSJ2MQVhbx8EZoI10oU8EKM195YBhn2Ce5N/6hR8/uYeZmerEJm
         sBpA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=RbM641x1;
       spf=pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=danielgutson@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id x25-v6sor6925201qto.101.2018.05.18.18.24.51
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Fri, 18 May 2018 18:24:51 -0700 (PDT)
Received-SPF: pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:ac8:2fe1:: with SMTP id m30-v6mr11973912qta.43.1526693091075;
 Fri, 18 May 2018 18:24:51 -0700 (PDT)
In-Reply-To: <2300193.1RphyUdPvq@tjmaciei-mobl1>
X-Original-Sender: danielgutson@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=RbM641x1;       spf=pass
 (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=danielgutson@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:38131
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/38131>

--0000000000005fecf4056c84ef4a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

El vie., 18 de mayo de 2018 21:16, Thiago Macieira <thiago@macieira.org>
escribi=C3=B3:

> On Friday, 18 May 2018 14:13:15 PDT Andrey Semashev wrote:
> > What is "the right thing"? Does it have to be a byte-granular operation=
?
> > Does it have to be a forward iteration? Is this behavior the same on al=
l
> > implementations? You have to answer on all these questions in the
> > standard wording so that everyone can rely on the exact memory access
> > pattern, which is important in case of volatile memory.
> >
> > If it is not important in your case then you don't need volatile and
> > hence the overload.
>
> On the other hand, if your memory storage requires a specific behaviour
> which
> cannot be standardised, maybe you should implement the copying directly i=
n
> your code. It's not like bytewise memcpy and memset are particularly
> difficult
> to implement...
>

Oh yes you don't know how hard it can get... :) avoid prefetching, avoid
SSE/vectorization, ensure right order of operations (WC regions).
So there are lots of details that a too smart toolchain may mess.
However I will think if an execution policy can help here in copy. I'm not
talking about copying but also memsetting.
The linux kernel has a nice memcpy_toio/fromio worth to look at.



> It's the SIMD-optimised with cacheline-alignment and such that are.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2300193.1Rph=
yUdPvq%40tjmaciei-mobl1
> .
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAFdMc-0wber%2BdL_ugAcg7OBxLoajOOU8mMqLmS-aKTWHR=
cCghQ%40mail.gmail.com.

--0000000000005fecf4056c84ef4a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">=
El vie., 18 de mayo de 2018 21:16, Thiago Macieira &lt;<a href=3D"mailto:th=
iago@macieira.org">thiago@macieira.org</a>&gt; escribi=C3=B3:<br></div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex">On Friday, 18 May 2018 14:13:15 PDT Andrey Semas=
hev wrote:<br>
&gt; What is &quot;the right thing&quot;? Does it have to be a byte-granula=
r operation?<br>
&gt; Does it have to be a forward iteration? Is this behavior the same on a=
ll<br>
&gt; implementations? You have to answer on all these questions in the<br>
&gt; standard wording so that everyone can rely on the exact memory access<=
br>
&gt; pattern, which is important in case of volatile memory.<br>
&gt; <br>
&gt; If it is not important in your case then you don&#39;t need volatile a=
nd<br>
&gt; hence the overload.<br>
<br>
On the other hand, if your memory storage requires a specific behaviour whi=
ch <br>
cannot be standardised, maybe you should implement the copying directly in =
<br>
your code. It&#39;s not like bytewise memcpy and memset are particularly di=
fficult <br>
to implement...<br></blockquote></div></div><div dir=3D"auto"><br></div><di=
v dir=3D"auto">Oh yes you don&#39;t know how hard it can get... :) avoid pr=
efetching, avoid SSE/vectorization, ensure right order of operations (WC re=
gions).</div><div dir=3D"auto">So there are lots of details that a too smar=
t toolchain may mess.</div><div dir=3D"auto">However I will think if an exe=
cution policy can help here in copy. I&#39;m not talking about copying but =
also memsetting.</div><div dir=3D"auto">The linux kernel has a nice memcpy_=
toio/fromio worth to look at.</div><div dir=3D"auto"><br></div><div dir=3D"=
auto"><br></div><div dir=3D"auto"><div class=3D"gmail_quote"><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p=
adding-left:1ex">
<br>
It&#39;s the SIMD-optimised with cacheline-alignment and such that are.<br>
<br>
-- <br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"noref=
errer noreferrer" target=3D"_blank">macieira.info</a> - thiago (AT) <a href=
=3D"http://kde.org" rel=3D"noreferrer noreferrer" target=3D"_blank">kde.org=
</a><br>
=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center<br>
<br>
<br>
<br>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank" rel=3D"noreferrer">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank" rel=3D"noreferrer">std-proposals@isocpp.org</a>.<br=
>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2300193.1RphyUdPvq%40tjmaciei-mobl1" =
rel=3D"noreferrer noreferrer" target=3D"_blank">https://groups.google.com/a=
/isocpp.org/d/msgid/std-proposals/2300193.1RphyUdPvq%40tjmaciei-mobl1</a>.<=
br>
</blockquote></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAFdMc-0wber%2BdL_ugAcg7OBxLoajOOU8mM=
qLmS-aKTWHRcCghQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-0wber%2B=
dL_ugAcg7OBxLoajOOU8mMqLmS-aKTWHRcCghQ%40mail.gmail.com</a>.<br />

--0000000000005fecf4056c84ef4a--

.
