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


Groups > comp.lang.forth > #20668

Re: Hosted Forths on multicore machines

From Bernd Paysan <bernd.paysan@gmx.de>
Newsgroups comp.lang.forth
Subject Re: Hosted Forths on multicore machines
Date 2013-03-14 17:56 +0100
Organization 1&1 Internet AG
Message-ID <khsvfj$e1c$1@online.de> (permalink)
References (2 earlier) <e0f429ac-b7ba-45ff-9900-293bd90cf992@oz4g2000pbc.googlegroups.com> <p-Sdndgja6PN1d3MnZ2dnUVZ_j2dnZ2d@supernews.com> <376c6d69-3339-4d48-8df3-1e04730e3ac0@y9g2000vbb.googlegroups.com> <eZydnctgMdVxDN3MnZ2dnUVZ_sqdnZ2d@supernews.com> <7xoben1g7l.fsf@ruckus.brouhaha.com>

Show all headers | View raw


Paul Rubin wrote:

> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>> Not necessarily: even a few laps of an empty loop or just retrying the
>> lock may well be enough.
> 
> I wonder if spinning is still reasonable with current cpu's, where
> memory accesses (to retry the lock) cost 100's of cpu cycles, and the
> energy dissipation from spinning is potentially costly in its own right.
> Is there any hardware assist for this type of thing?

Transactional memory should give us the necessary assists.  The way a 
transactional memory works has two parts: One side to observe others 
stealing the cache-lines you read from within the transaction, the other is 
to commit the stores you made as atomic writes.  Fortunately, most of what 
you need there as hardware has been available for literally decades...

So you have a few cache lines to observe, and a few cache lines to keep as 
uncommitted copies.  The code looks like

begin transaction
  do some reads
  do some computations
  do some shadow writes
atomic commit

If you lost some reads or someone messed with the cache lines you write 
into, the atomic comit will fail and jump again to the begin.

Now, if you are waiting for a lock, you might want some "pause", i.e.

begin transaction
  read a lock
  check if it is free
  if not: pause and repeat
  do a shadow write to aquire the lock
atomic commit

PAUSE here would mean "wait until one of the observed cache lines is 
modified".  My PAUSE would have a timeout, because when the timeout expires, 
you should rethink your spin loop strategy, and do a full block.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-11 14:17 -0700
  Re: Hosted Forths on multicore machines "Clyde W. Phillips Jr." <cwpjr02@gmail.com> - 2013-03-11 17:41 -0700
    Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-12 06:38 -0700
  Re: Hosted Forths on multicore machines Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-12 02:19 +0100
    Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-12 06:05 -0700
      Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-12 06:34 -0700
        Re: Hosted Forths on multicore machines Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-13 01:51 +0100
      Re: Hosted Forths on multicore machines "Elizabeth D. Rather" <erather@forth.com> - 2013-03-12 09:46 -1000
        Re: Hosted Forths on multicore machines Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2013-03-13 11:30 +0100
      Re: Hosted Forths on multicore machines Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-13 04:35 -0500
        Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-13 06:55 -0700
          Re: Hosted Forths on multicore machines Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-13 09:49 -0500
            Re: Hosted Forths on multicore machines Paul Rubin <no.email@nospam.invalid> - 2013-03-13 08:18 -0700
              Re: Hosted Forths on multicore machines Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-13 10:39 -0500
                Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-13 16:36 -0700
                Re: Hosted Forths on multicore machines Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-14 03:44 -0500
                Re: Hosted Forths on multicore machines anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-14 09:06 +0000
                Re: Hosted Forths on multicore machines Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-14 06:26 -0500
                Re: Hosted Forths on multicore machines anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-14 15:41 +0000
              Re: Hosted Forths on multicore machines Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-14 17:56 +0100
                Re: Hosted Forths on multicore machines Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-15 03:26 -0500
                Re: Hosted Forths on multicore machines Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-16 23:11 +0100
  Re: Hosted Forths on multicore machines Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-12 05:01 -0500
    Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-12 06:10 -0700
    Re: Hosted Forths on multicore machines Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2013-03-12 17:04 +0100
      Re: Hosted Forths on multicore machines Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-12 11:28 -0500
        Re: Hosted Forths on multicore machines Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2013-03-12 19:52 +0100
      Re: Hosted Forths on multicore machines morrimichael@gmail.com - 2013-03-12 10:11 -0700
        Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-12 11:34 -0700
        Re: Hosted Forths on multicore machines Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2013-03-12 19:44 +0100
          Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-12 13:13 -0700
            Re: Hosted Forths on multicore machines Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2013-03-15 15:44 +0100
              Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-15 09:37 -0700
      Re: Hosted Forths on multicore machines Alex McDonald <blog@rivadpm.com> - 2013-03-12 11:37 -0700
        Re: Hosted Forths on multicore machines Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2013-03-13 10:46 +0100
  Re: Hosted Forths on multicore machines the_gavino_himself <visphatesjava@gmail.com> - 2013-03-12 15:22 -0700

csiph-web