Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5338

Re: Optimization problem

From Nobody <nobody@nowhere.com>
Subject Re: Optimization problem
Date 2011-05-22 15:01 +0100
Message-Id <pan.2011.05.22.14.00.59.484000@nowhere.com>
Newsgroups comp.lang.c++
References <e627bb96-b05b-43ac-b6e8-e0ddaf62f9cc@l30g2000vbn.googlegroups.com> <db3320a1-d7d6-4337-af40-10ea1b9a76ee@q12g2000prb.googlegroups.com> <bdb12766-bf2e-4b3c-ab57-7f07e0e530f9@j25g2000vbr.googlegroups.com>
Organization Zen Internet

Show all headers | View raw


On Sun, 22 May 2011 01:47:20 -0700, hamze wrote:

> I know what is my hardware correct order of MMIO, but I dont know how
> to make compiler know about it and force compile not to REORDER my
> code.

The compiler will not re-order reads/writes of volatile variables with
respect to each other. However, the CPU might perform re-ordering; to
prevent this, you need to use a memory barrier (aka "fence").

	http://en.wikipedia.org/wiki/Memory_barrier
	http://en.wikipedia.org/wiki/Memory_ordering

For gcc, see e.g.:

http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Atomic-Builtins.html

Also, you might try comp.arch.embedded.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Optimization problem hamze <hamze60@gmail.com> - 2011-05-21 23:29 -0700
  Re: Optimization problem Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-22 01:25 -0700
    Re: Optimization problem hamze <hamze60@gmail.com> - 2011-05-22 01:47 -0700
      Re: Optimization problem Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-22 11:40 +0000
      Re: Optimization problem Pete Becker <pete@versatilecoding.com> - 2011-05-22 08:39 -0400
      Re: Optimization problem Nobody <nobody@nowhere.com> - 2011-05-22 15:01 +0100
      Re: Optimization problem Geoff <geoff@invalid.invalid> - 2011-05-22 09:14 -0700

csiph-web