220 38152 <5B0520CD.30204@gmx.net> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Jens Maurer <Jens.Maurer@gmx.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: memcpy/memset/etc overloads for volatile memory
Date: Wed, 23 May 2018 10:05:33 +0200
Lines: 62
Approved: news@gmane.org
Message-ID: <5B0520CD.30204@gmx.net>
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> <CAFdMc-0wber+dL_ugAcg7OBxLoajOOU8mMqLmS-aKTWHRcCghQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1527062609 2395 195.159.176.226 (23 May 2018 08:03:29 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 23 May 2018 08:03:29 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDPMTYGK64JRBTWBSTMAKGQEQVL7SMY@isocpp.org Wed May 23 10:03:25 2018
Return-path: <std-proposals+bncBDPMTYGK64JRBTWBSTMAKGQEQVL7SMY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f199.google.com ([209.85.128.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDPMTYGK64JRBTWBSTMAKGQEQVL7SMY@isocpp.org>)
	id 1fLOk0-0000WH-Bi
	for gclcip-std-proposals@m.gmane.org; Wed, 23 May 2018 10:03:24 +0200
Original-Received: by mail-wr0-f199.google.com with SMTP id t15-v6sf13282866wrm.3
        for <gclcip-std-proposals@m.gmane.org>; Wed, 23 May 2018 01:05:36 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1527062735; cv=pass;
        d=google.com; s=arc-20160816;
        b=TfS2iIIJFJox6bwrS9ZC6Thsa9IbAJTUf+JTB4g92TMcRVU+TIaBTO4h/wNy2qMrh2
         jqE1dcPJDGbcwiCFAOWJ75oX7Y3ZlLDSB1pG3lSZi4zC8QrA1yueOPQ30eknFH3xafs/
         u3XzPe2vrdqRaarrS8DBo8akAnW6hW8ZYEvJ2b1nSX1huHzXqMUYFWUego8hfWzuYeG/
         r2ReJgXChTFJ4eVsyDvOB4TTB1AlW5yiapwJuK3mPK+XPlDcgsT79n4NfYaueaAhY2eS
         aeOak7EXKpKJrKAsXAaz3WRjuQVDlCQlK2645cqAI4v6JlL3YeVeHEou/pkTbwYT2fqY
         ygvg==
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:content-transfer-encoding
         :in-reply-to:references:subject:to:mime-version:user-agent:from:date
         :message-id:arc-authentication-results:arc-message-signature
         :dkim-signature:arc-authentication-results;
        bh=z8bUwiRZv3NVrVwmFfF9U7F6CYyd86+F44EWZfGHJRs=;
        b=taDV/O8pxqBPbGOypSN7/CNAtX3a2NRpi4Rsvi68/8tiZIU5EEYWlW3+8eGMjjKuxj
         hEvAEK2FH4UyRi+CX9fIte/IHodnuGAUDV6wQWxrdY/vyVS+2WpGSMwSdIDdhg1hkKBA
         xkOY3P8jBBqD+nMShRqAJmTmATKMfUa4X/rB8gB+PqRPRbvyOxpM8hJa0dx43aYSORwF
         l1QcVSPPm3KG7n6ZlLfrjYH2uTEKn+21iebAIHg2RYtPKB+xqyDLgBKgYLCT81l5H6+x
         1JA8tJCupd71OAo9iEo58k9wOpjtv3ccv8XCXTc603h8aft5bW7WG/PQmbSp2WtjP/Bf
         b 
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of jens.maurer@gmx.net designates 212.227.15.18 as permitted sender) smtp.mailfrom=Jens.Maurer@gmx.net
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=message-id:date:from:user-agent:mime-version:to:subject:references
         :in-reply-to:content-transfer-encoding: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=z8bUwiRZv3NVrVwmFfF9U7F6CYyd86+F44EWZfGHJRs=;
        b=AZP01okshEzBQBaBXQsN4s9VDCxRWOZZ8O9fQqv9y9v3CllwHbIWAmA2iOhbN0o5lJ
         3w1kLaWypvtYC1gBtduLMQEASiN7+lxdibOrMvGsC3T+IegEFIrezJKvYfZp0jjD9wJj
         TneEUx0q2JI8mx11QDctkmoeS3oFCklUPVxwSHQa9d9dnM1vJnoTfnSqW2EYXAAxL09M
         XHWW5uHMbYaTnCuIQI5B4Cg8cjjTL25FtTT7i2IkEopZ3sIpKj8R1TTaOrqjuIX2/drf
         n+WLgIZxexgwUKLpEYPo/yO9NVc8WqVtXfwT5ZPrIrwxILm9fr86A4o5kpcMVFvp/Ntu
         4KWg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to
         :subject:references:in-reply-to:content-transfer-encoding
         :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=z8bUwiRZv3NVrVwmFfF9U7F6CYyd86+F44EWZfGHJRs=;
        b=VcvbtDjeawc8lPlm4WQwQ7vMBv+/a724XuCIb5gXn0GUc4P6d2FYjRQK/OCdl9WFbA
         NR/6MZV2k5MZgFBHu7CkwVLqKBlS+IptJuX5JmRWtaFpk0Iv1aIadvda3AU5yj+nVwUs
         ID2ADlTKQoEUWPnK9cz0uNvzROmrptgr6cXnbFRmI2jwFefg9YdCAaosiSrsdPVQaP9W
         j4ERBsorKYCRUiFY3XJOhvoe/IIWShs7PKn5NS6qZAmHS3NXu2qSwUPv+18uppkkjTyV
         Aeq1hlDJ1bquhaGUxzeZHD/OJod2qi1gY3W3f2dK3zvd8WDDG3xtJiZnSpl7icXui1KN
  
X-Gm-Message-State: ALKqPweKjSUAT39DwiEt61WBBmXHhsVJGQ8WCli6D56CQX0B2GzeYjcf
	lDfD1xiOFp6a4ChhyUjEFvMmlg==
X-Google-Smtp-Source: AB8JxZpr7eBFnOV5ePdbAq901pCmtyElDT9dOek8FTm2iMYyJS3sQDb3gjDN632b4DJfFpOxKYo/5Q==
X-Received: by 2002:a1c:8985:: with SMTP id l127-v6mr419069wmd.24.1527062735765;
        Wed, 23 May 2018 01:05:35 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a1c:d389:: with SMTP id k131-v6ls2769513wmg.7.gmail; Wed, 23
 May 2018 01:05:34 -0700 (PDT)
X-Received: by 2002:a1c:455d:: with SMTP id s90-v6mr3102306wma.156.1527062734508;
        Wed, 23 May 2018 01:05:34 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1527062734; cv=none;
        d=google.com; s=arc-20160816;
        b=kZ4e7x4tvtxKmSGZjxCXuxux2NPEgZ8GoXpT7AjRC9TC4mgwqEsNo5LKLp+w47bBVu
         0oi8vwv6A+2o0qBkbMPqTfyBHxzQvqFVRvfa77UNF1+HigM0YcV2TGKnusiR3LOYLVhi
         1XgAlLelwhNOKcOJ/zez3GypqxX23ck47IDxJT5PKtVLL7yfzvt1lbWGkHiWw8Byqcux
         +1uHRGQhhDpdbfQWWm1bqGtwLMSk4baJmK6/5Ger6lZIVVmI1d6lfQNCJUN0fHfgTPMK
         /qEX5R6Njqh+1jPTBdS9tb+NmuroazDaXigFVTg96K6j9SIvUQkm64P05wPQ90Vl6/s1
         jZyA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:in-reply-to:references:subject:to
         :mime-version:user-agent:from:date:message-id
         :arc-authentication-results;
        bh=p1vDrDbMkpsfEauk9QP15bELxxHg2j0y4GpfauEVFLQ=;
        b=SXlbF9H/nnC313c3aYU1xjnZMUhR7pFYgvzt+4cRPUMNxNMOkXDW5VjBfn5qk+kA/t
         s8l4EX438w1DbIOfacUJM8iY3LCJfTDEXwtuTlJZb3TvIGNL8vZLqEqwRhn+2USfHI5A
         B160hv104geWHXMdX9wLGz7FxRq0GvVoZhdPRoRhIHHXgnhF81NuZngmp3/X/fxW3j+R
         tdOHTSKudqelWWc/3P5dYbN36L6rCkOTQrLtxHRZgjj9pI9kVRuAPTFrGfkMQWQWvalY
         yZgu1WubDZa9aoGuYKbUrmsSk3J1S5KzfrwDRd7FAWf0+hFpLoogFVhFb4q6NX8cA57H
         M19w==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of jens.maurer@gmx.net designates 212.227.15.18 as permitted sender) smtp.mailfrom=Jens.Maurer@gmx.net
Original-Received: from mout.gmx.net (mout.gmx.net. [212.227.15.18])
        by mx.google.com with ESMTPS id e185-v6si1384848wmg.9.2018.05.23.01.05.34
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 23 May 2018 01:05:34 -0700 (PDT)
Received-SPF: pass (google.com: domain of jens.maurer@gmx.net designates 212.227.15.18 as permitted sender) client-ip=212.227.15.18;
Original-Received: from [192.168.2.101] ([188.101.152.160]) by mail.gmx.com (mrgmx001
 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MF5FT-1fb4Ew3JjX-00GHP7 for
 <std-proposals@isoc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L
 8Y5CSVg8xG+H0Bs78sDfYTKA4Q1knRE41FeUoc2x5Buzb8KxVKXEusfPeapD6L9WhbucUUMoX
 jnfLqOQP+nO4KjobWVHmorNbyOsDv0oV+e6PboZ5UWy7qIWlch3LKs7a9I7gGbs2sFadZNGF 
X-Original-Sender: Jens.Maurer@gmx.net
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of jens.maurer@gmx.net designates 212.227.15.18 as permitted sender) smtp.mailfrom=Jens.Maurer@gmx.net
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:38152
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/38152>

On 05/19/2018 03:24 AM, dgutson . wrote:
>=20
>=20
> El vie., 18 de mayo de 2018 21:16, Thiago Macieira <thiago@macieira.org <=
mailto:thiago@macieira.org>> escribi=C3=B3:
>=20
>     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 opera=
tion?
>     > Does it have to be a forward iteration? Is this behavior the same o=
n all
>     > implementations? You have to answer on all these questions in the
>     > standard wording so that everyone can rely on the exact memory acce=
ss
>     > pattern, which is important in case of volatile memory.
>     >
>     > If it is not important in your case then you don't need volatile an=
d
>     > hence the overload.
>=20
>     On the other hand, if your memory storage requires a specific behavio=
ur which
>     cannot be standardised, maybe you should implement the copying direct=
ly in
>     your code. It's not like bytewise memcpy and memset are particularly =
difficult
>     to implement...
>=20
>=20
> 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 no=
t talking about copying but also memsetting.
> The linux kernel has a nice memcpy_toio/fromio worth to look at.

"volatile" only conveys a single bit of information, but
modern architectures need a lot more data to actually do
what you want if the "memory" isn't your usual kind of
RAM with a cache hierarchy on top.  For example, it might
make a difference whether you copy bytewise or wordwise (and
both options might be useful in different circumstances).
For example, you might need to expressly synchronize writes
with later reads.

Since you mention the Linux kernel, note that it has a lot
more than just a volatile memcpy to deal with all these
issues.  Maybe there's a general enough abstraction hidden
in there somewhere that we could eventually standardize, but
just having a volatile memcpy is neither here nor there.

Jens

--=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/5B0520CD.30204%40gmx.net.

.
