Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Anyone know CUP cache and java array?

Thread view: 
Kevin - 03 May 2006 17:21 GMT
I think the CUP needs to load the data structure to its CPU cache in
order to operate them, right?
So when we have a java array, for example:

int[] myArray = new int[2000];

When I want to update one of its values, for example:

myArray[1000] = myArray[1000] + 1;

In order to process this line, will the CPU load the whole array into
its CPU cache to process? Or it can just load that particular item to
its cache to update it?

Thanks.
Oliver Wong - 03 May 2006 17:36 GMT
>I think the CUP needs to load the data structure to its CPU cache in
> order to operate them, right?
[quoted text clipped - 9 lines]
> its CPU cache to process? Or it can just load that particular item to
> its cache to update it?

   Probably the latter. You can make arrays that, as a whole, are too big
to fit into cache.

   - Oliver
Dimitri Ognibene - 03 May 2006 17:52 GMT
The cpu, usually, doesn't know anything about arrays so it works only
on elements.
However the cpu or the memory interface can load a whole segment of
data near to  the memory element you are accessing..but you can't have
any control on this behavior, which however is enough fast, it is
usefull for cicles on array..
Dimitri
Eric Sosman - 03 May 2006 17:50 GMT
Kevin wrote On 05/03/06 12:21,:
> I think the CUP needs to load the data structure to its CPU cache in
> order to operate them, right?

   Usually, yes.  Note that most modern computers have
multiple levels of cache with different characteristics.
Also, it may be possible to do some kinds of manipulation
(e.g., block copies) without involving some caches.

> So when we have a java array, for example:
>
[quoted text clipped - 7 lines]
> its CPU cache to process? Or it can just load that particular item to
> its cache to update it?

   In one sense you don't know.  You write this line of
Java, javac compiles it, and the JVM executes it ... somehow.
The details of the execution are (mercifully -- take my word
for it) hidden from you.

   In another sense, it's easy to get at least a partial
answer.  Choose whichever cache level interests you and
consider its size.  Then write a Java program with an array
of, say, five times that size.  Do you think your program
will run, or do you think the CPU cache will explode like
Mr. Creosote after the "waafer-thin" mint?

Signature

Eric.Sosman@sun.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.