Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Sep 1996 23:39:32 -0700
From:      erich@uruk.org
To:        Terry Lambert <terry@lambert.org>, smp@csn.net (Steve Passe)
Cc:        peter@spinner.dialix.com, rv@groa.uct.ac.za, freebsd-smp@freebsd.org
Subject:   Re: Intel XXpress - some SMP benchmarks 
Message-ID:  <199609130639.XAA14603@uruk.org>
In-Reply-To: Your message of "Thu, 12 Sep 1996 14:42:50 PDT." <199609122142.OAA07599@phaeton.artisoft.com> 

next in thread | previous in thread | raw e-mail | index | archive | help

Terry Lambert <terry@lambert.org> writes:

> > if we have sparse tables, ie 16 entries (most of which will be empty), code
> > like the following becomes very inefficient:
> > 
> > #ifdef SMP
> > 			for (j = i = 0; i < SPARSE_TABLE_SIZE; i++) {
> > 				if (p == SMPcurproc[i])
> > 					j++;
> > 			}
> > ...
> 
> Use it like a hash:
> 
> #ifdef SPARSE
> int	cpuid[ MAX_CPUID];	/* filled out by probe sequence*/
> #define	CPUID(x)	(cpuid[ x])
> #else	/* !SPARSE*/
> #define	CPUID(x)	(x)
> #endif	/* !SPARSE*/
> 
> Obviously, this would save one indirection per reference, which shouldn't
> be too frequent anyway.

I use a virtual CPU mapping scheme which is:

  --  BSP -> virtual number 0
  --  others mapped consecutively from there  (doesn't really matter which
	order, but I use APIC id order).

Well, the way I'm doing it now in the code I'm writing is something
like:

	int  apic_to_virtual[MAX_APIC_ID];
	int  virtual_to_apic[MAX_CPUS];
	#define CPUNUM(x)  (cpunum[x])
	#define CUR_CPUNUM()  (cpunum[cur_apicid()])

The APIC register reference takes so long that the array reference is
simply absorbed in the overhead.  I always get the virtual number (and
possibly the APIC id, if necessary), then operate from there.

Walking a sparse array takes up enough other overhead (checking for
whether you're done as well as not using non-existent entries)
that translating back to the actual APIC ID is OK.  If anything it
simplifies the code to walk only consecutive numbers.

--
  Erich Stefan Boleyn                 \_ E-mail (preferred):  <erich@uruk.org>
Mad Genius wanna-be, CyberMuffin        \__      (finger me for other stats)
Web:  http://www.uruk.org/~erich/     Motto: "I'll live forever or die trying"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609130639.XAA14603>