Can You Spare A Few Trillion Cycles? 570
"The plan is to run the program on a zillion machines for a month and combine the results. All you have to do is run it and when the deadline arrives, email me a compressed file of the cache directory. So email me here and I'll send you the zip file. The deadline will be June 1st 2004.
The running program has a More CPU/Less CPU button. Every half hour it saves the current state of the film. The longer and more machines that run this, the cleaner and sharper the image gets. If you have a lot of machines, I can give instructions how to combine the results so you can send in a single cache directory.
Of course, you will get mention in the article if it gets published."
Real URL to image (Score:4, Informative)
The URL to the photo soup image is missing the 'www'. The image can be seen here [cpjava.net] (you may want to do a 'Save Target As', as the mime-type seems to be a bit off).
Mirror (Score:1, Informative)
The original was silly, too -- it sent back the image as Content-Type: text/plain. I don't understand it at all, but since the server is toast now, it doesn't really matter either way.
Re:Java? (Score:3, Informative)
Broken link, java jab (Score:5, Informative)
People are already cracking jokes about how the fact that it's in Java will mean that it will run a lot slower than it could. While I love to pick on Java as much as the next person, I am curious how much it actually makes a difference for raytracing - does anyone know? My experience with numerically-intensive algorithms is that Java is 2-4x slower than C. You can get it within 2x of the speed of C if you ignore object-oriented programming and you're really good at Java optimization, but that's it. And it will run much slower on some architecetures because Java guarantees certain floating-point operation semantics at the expense of speed.
If I were writing a new numerically-intensive program from scratch that I wanted to use for a cross-platform distributed computing project, I'd probably do it in Numerical Python (NumPy) [pfdubois.com] - my experience has been that it can be within a factor of 2-3 of the speed of C, but it's much more concise, requiring half as many lines of code as Java or C to do the same thing. And these days Python is just as cross-platform as Java - it definitely runs great on Mac, Windows, and Unix.
Re:Java can be faster then C sometimes (Score:4, Informative)
Astounding.
Photon Soup: Longer and Uncut (Score:5, Informative)
Re:Broken link, java jab (Score:5, Informative)
1. Learn to use java -Xprof. This is a rudimentary profiler, but even the most basic data is useful. Concentrate on the parts that get the most use.
2. If -Xprof says the garbage collector is taking more than about 1-2% of the cpu, it's a problem. If it's at 10%, it's costing you well more than 10% speed -- lots of reasons, like cache misses, thread switching, and the allocations in the first place.
3. Don't delete objects in the main loop. Use factory methods and the like if you have to. This is how you decrease GC times.
4. Some of the standard API pieces are very slow. I've had particular trouble with anything related to the Collections framework, and Strings are even worse. Avoid these.
Now, all this takes work, but it's not particularly harder or easier than doing good optimization of C Code.
Could you please configure your server properly? (Score:2, Informative)
[snip]
Found www.cpjava.net in host_name_addresses_map (0x8074330)
Registered fd 3 for persistent reuse.
Length: 71,283 [text/plain]
[snip]
Apparently your server is sending out
Numpy is great, but... (Score:3, Informative)
Re:Java? (Score:5, Informative)
Re:Java can be faster then C sometimes (Score:5, Informative)
Re:Bad link (Score:4, Informative)
Try this [cpjava.net]...
you need to work on your java skills then... (Score:5, Informative)
My experience with numerically-intensive algorithms is that Java is 2-4x slower than C. You can get it within 2x of the speed of C if you ignore object-oriented programming and you're really good at Java optimization, but that's it. And it will run much slower on some architecetures because Java guarantees certain floating-point operation semantics at the expense of speed.
The speed difference oft cited is about 20% on numerical apps. Check out http://www.idiom.com/~zilla/Computer/javaCbenchmar k.html [idiom.com]. He brings up "
Benchmarking Java against C and Fortran for Scientific Applications [philippsen.com] as well.
You have to remember that Java's speed disadvantage is mainly in the JVM startup and GUI areas. Although a good Java dev team can make Swing fly ( checkout JBuilder for instance ).
Java being Just-In-Time compiled can even take advantage make runtime optimizations that your C/C++ application may not.
Re:Java can be faster then C sometimes (Score:3, Informative)
If your program has a noticeable performance benefit from using SIMD instructions, you can move the relevant functionality into a shared object, and distribute the program with several versions of it, and dlopen() the correct one at runtime. The absence of programs that actually bother doing this, can serve as an indicator as to how big the performance benefit from SIMD optimizations really is.
Does that explain it better?
Re:Povray ? (Score:2, Informative)
Photon simulation does the opposite of ray tracing and traces the paths of photons leaving the light source and calculates where each photon would hit the view plane if at all. It takes a lot of calculation because you have to send of millions of photons in all directions from the light sources. You can simulate all known light effects this way, just very very slowly. In the image you can see light shining from the light source onto the rear mirror and bouncing off onto the diffuse surfaces at the side.
Both are great for parallel processing because each photon/ray is pretty much independent of others.
Re:Java? No wonder you need cpu cycles. (Score:4, Informative)
For Java haters, here're the benchmarks you need (Score:2, Informative)
While Java is not "unacceptably slow" or "1000 times slower" as some claims, it is generally slower than C and much more resource intensive nevertheless.
Actually if one wants to write this kind of math intensive apps, pure Java is really not the best choice. Even pure C isn't. He should think about implementing some of the highly used routines in assembly (no joke). And since photon tracing can be done parallelly, one would find the SSE and 3DNow! families of instructions useful.
And finally, besides the CPU, you can also try to do the calculations in your GPU. You'll need a new-fangled PCI-X card in the future to do the calculations efficiently tho.
Take a look at this site BrookGPU [stanford.edu]
Re:Oh boy... (Score:3, Informative)
Incidentally, C99 has very nice support for IEEE 754 (improved numerics support was, in fact, one of the biggest additions compared to the old C89 standard).
Java has come a long way since 1998 (Score:5, Informative)
I need cycles, too! for spin glasses... (Score:4, Informative)
Spin glasses are systems in with the interactions between magnetic moments are in conflict with each other. These competing interactions make these systems extremely hard to simulate at low enough temperatures. If you have a linux box sitting around idle which is fast enough, let me know and I will provide you with some samples to run. Current project: 100 - 300 samples, each takes ~ 10 days on a 2.4 GHz Xeon... For information on how to contact me, go to duamutef.ethz.ch [duamutef.ethz.ch]. Of course your name will be mentioned if you compute a considerable number of samples!
Re:Java? No wonder you need cpu cycles. (Score:2, Informative)
Re:A qualified "yes" (Score:2, Informative)
Re:Broken link, java jab (Score:4, Informative)
Re:Java eh? (Score:4, Informative)
pop AX
STOSW 0x0005
pop AX
STOSW 0x0005
Even though the code may be running on a Pentium Pro (which is optmized for 32 bit code), it's still going to execute those 4 statements.
Now, the Java Hotspot compiler will start and notice the fact that you're running on a Pentium Pro. So when it converts the bytecode to machine code, it creates the following instructions:
pop EAX
STOD 0x0005
That's twice as fast as the C code!
Real code would tend to be running on modern processors, so this example is a little contrived. However, the JVM can (and will) use SSE instructions to do multiple calculations in one instruction, while the C code will be forced to generate non-SSE instructions to support the old Pentium Is out there.
Hotspot is also capable of analyzing the running code and regenerating even better assembly that would perform poorly in other circumstances. For example, let's say Hotspot notices that the bounds can't be exceeded on an array. Well, Hotspot will then recompile to remove the bounds checking.
Does that explain it better?!
--
This post is open source, retransmit as desired.
Re:Java eh? (Score:2, Informative)
Compilers are quite capable of finding out or being told what architecture to compile for and this includes various x86 types. Sorry , but your argument is invalid.
Re:Java eh? (Score:1, Informative)
Re:Anonymous grid computing (Score:3, Informative)
Most (all?) universities already have an authentication-system in place that is used on campus-computers, both for local and remote login. This can be applied to grid-computing, too. That way you can punish those who abuse resources like you already do if somebody decides to convert a couple of your loginservers into a CS/HL/Tetrinet/*-gameserver..
At my university, the charge for CPU-cycles on the high-performance clusters isn't really related to the actual cost of cycles as these are dirty-cheap today, but the cost of administration of the system. In the case of using desktop/login-machines for grid-computing this should already be covered by the "dayjob" of these computers.
Re:Wireless or not... (Score:3, Informative)
It was stolen via the anti-slash.org database
Mod parent down.
Re:Trust? (Score:3, Informative)
-
Re:Java eh? (Score:5, Informative)
rkeene517 is asking for volunteers to run the program. If rkeene517 does it in C/C++ then rkeene will have to compile for the different x86 types and ensure that volunteers download the right binary. From experience you end up getting a high number of people getting the generic x86 binary instead of the optimized one because in order to avoid zillions of support queries, you have a "If you are unsure, click on i386".
Of course you could bundle all the various binaries and add code or a binary that figures out what x86 it is and runs the relevant binary.
But that involves a step more than what you suggest.
Re:Java eh? (Score:4, Informative)
Sure, you can configure compilers as narrowly as you like, but in most cases, compliation will be targeted at the lowest common denominator.
If your compiling for yourself, you have the luxury of building for your own CPU. This isn't the case here.
Why do you think Linux binary rpm's, for years, were compiled for 386 chips. It's only recently that some (all?) distributions have started distributing 586 based rpms.
The point is, Java can make this decision at run-time, and hence target the actual CPU. C++ code can not (without a lot of pain, at least).
Re:Java eh? (Score:2, Informative)
Startup time is still an issue, but for most apps it's not much of a problem.
Re:isn't this duplicate work (Score:4, Informative)
Re:Java eh? (Score:1, Informative)
the RC1 of the Blackdown JDK 1.4.2 on Linux and then revert your statement
Over here on my machine pure Swing on Blackdown 1.4.2RC1 is faster than GTK2 but a tad slower than Qt.
On Windows there is no noticable difference between Swing and native Controls anymore speedwise.
Both use hardware acceleration functions of the underlying graphics card, so no big deal here anymore.
Re:Photons (Score:3, Informative)
Now: assuming the LED is 100% efficient (close enough) and that your pupils are (eg.) 1 square cm at (eg) 1m from the source, you can calculate how many photons / second were entering your eye.
Of course we were young (hmm, 17?) and this is only an order or magnitude experiment, but most people could go down to somewhere around 1 - 10 photons / second.
Re:Photon Simulation vs Raytracing (Score:5, Informative)
Ray tracing: "reverse ray tracing". Emit "sight rays" from the eye, have them bounce off scenery, and see where they hit light sources.
That's simplifying, of course.
Forward ray tracing was here first, but was quickly (all but) abandoned, since it is computationally way more intense (why, 10 years ago, it would have taken 100 Sparc Station 1's an entire month just to calculate one small image!). Imagine simulating a zillion photons just to discover that over 0.99 zillion had failed to reach the eye...
On the other hand, it is physically more correct, since effects like caustics are very difficult to do right in "reverse" ray tracing.
Re:Java eh? (Score:3, Informative)
A slightly odd looking mirror (from google) (Score:3, Informative)
Re:Java can be faster then C sometimes (Score:2, Informative)
1) Programmer time goes for about $50/hr. That means that a prrogrammer spending 20+ extra hours could have pretty easily bought you an extra dual CPU computer to run the thing on. That's only 2/3 days of work. Java can easily shave off much more than that.
2) Java isn't that slow. Depends on what you're doing and how you're doing it, but it's not crazy to get java to be less than 50% slower than C. It's also not really uncommon for it to be faster. When it is faster it's almost always because better algorithms are used, but that isn't an accident. It's much easier to write good algorithms with a garbage collector sometimes, as you don't have to track down and delete all the stuff you unlinked.
3) The one weakness of java (until VM sharing becomes available) is memory usage, but memory is really cheap now, same basic logic as CPU time, but even more so.
4) Lots of additional optimizations are possible in VM based languages that aren't tried by any modern VM. When they start to come online, expect the performance of the VMs to surpass compiled code. Here are some examples....
a) Escape analysis: all stack frame scoped data goes on the stack. Basically it makes optimal use of the stack, can't really be improved any. This is why C#'s "value" types are so stupid, they shouldn't be able to help (and would probably hurt) a good VM. Anything larger than a pointer should be a reference, the VM can put it on the stack if it's possible to do so.
b) Method virtualization: a good VM should strip down pretty much all of the V-tables and just regenerate what it actually uses. This is why the "virtual" keyword in C# is so stupid, it should have no effect on performance assuming a smart VM. Can also do all sorts of inlining that a normal compiler can't do (someone could link to your library, you can't inline away public functions).
c) "incorrect" optimizations: The VM can create optimal code that is not actually a valid representation of the given code for all inputs. Can then revert the code if an input is given for which it is not valid.
d) Profiling: a VM can (and modern ones do) profile the code and optimize the common cases at the expense of the uncommon ones.
e) Hardware knowledge: a VM can always produce code that is optimal for exactly your hardware, right down to cache sizes, processor model, and memory latency.
Just though I'd throw these things in. Those who expect VM based languages to always be slower will probably be in for a shock in the future. Remember, the cost of compilation is basically constant whereas the payoff from optimizations is linear in CPU speed. At one point the optimizations will exceed the cost of compilation. It's only a matter of time.
But HotSpot compiles and RECOMPILES on the fly (Score:5, Informative)
For instance, let's say you have an interface I, and a class X that implements I. If X is the _only_ implementation of I loaded at the moment, then all calls to methods on I can be direct, non-virtual calls because there's only one choice! In fact, HotSpot will even inline the method calls if it decides it will be beneficial.
But then a class B is loaded. HotSpot will de-optimize the inlined and direct calls to methods on I.
There are many more examples, such as loop bounds-checking elimination, and other things HotSpot can do because it sees the state of the running system.
If you've used a slow Java program, it's no doubt the result of a poor design and coding job by the programmer. "I'll just pick up Java for Dummies in 24 Minutes. Now I'm a 1337 j4v4 h4x0r!!" You may also have been using an old, slow JVM. The performance increases between Java 1.2, 1.3, and 1.4 are truly awesome. Also, Sun's Java 1.5 starts up on my machine in less than half the time that 1.4.2 did, and the graphics as OpenGL accelerated now, ... the list goes on and on. For anyone who had used a Java IDE, especially NetBeans/Forte (which I like, except that it's so freakin' slow I fall asleep between operations), you must try IntelliJ IDEA [intellij.com]. It is so responsive and just a joy to use. On the systems I've run it on, it is significantly more responsive than Eclipse.
Re:Photon Simulation vs Raytracing (Score:3, Informative)
Re:Explain picture (Score:5, Informative)
Re:Photon Soup: Longer and Uncut (Score:3, Informative)
Sick of the clueless blasting Java performance... (Score:4, Informative)
This thread is already full of very knowledgable people expoudning at great length as to why Java is not slower (and infact, is often faster than "native code"). Therefore, I will not waste my time writing an indepth response to those who would argue that 1 + 1 in Java is somehow slower than 1 + 1 in C/C++. This post [slashdot.org] does that quite well. What that comment does not do, however, is explain why some Java programs do, in fact, feel slower than native programs.
I'll simplify this as much as I can without diverging from the technical truth too much. Most complaints that Java is slow come from two sources. First, you must wait for the virtual machine to load, and depending on the libraries used by the program, that can be costly in terms of IO, which is always very slow. Second, Java's GUI toolkits are fairly heavy weight--they do a lot and many programs take advantage of much of the functionality they provide. I won't embark into the details, but to those inclined to find out why should read more about Swing and what Java2D libraries offer. Because of all they do, many Java programs with GUIs feel a little sluggish. Of course, keep in mind that most software sits idle 99% of the time while the user decides what to do. So otherwise, Java code that is not bound by user response time is very fast.
One quick post script: because the Java language is object oriented, complex software will do a great deal of memory allocation and garbage collection as objects come in and out of use. That too, is very expensive. However, there is no reason that you have to use the Java programming language to code for the virtual machine. Case in point: Jasmin [nyu.edu]. In theory, you could write compilers that generate JVM bytecode from any language (and a former professor of mine is currently in the proceess of writing a book that explains precisely how to do that).
Re:Trust? (Score:3, Informative)
View photons at home, $25 (Score:3, Informative)
Re:Oh boy... (Score:3, Informative)
This is a very special case he has - HPC. It's one of the few that actually do benefit from hand-tuning optimizations in some places.
The asm optimization is optimizing algorithms. It usually is the last stage, when you still need to squeeze more speed after all the high-level optimizations. Not very often, but it still happens (see openssl use of asm for instance; heck, even ATL/WTL - that's a Windows C++ template class lib - uses a couple of asm lines).
So no, asm is not dying outside compiler writers
Re:Sick of the clueless blasting Java performance. (Score:4, Informative)
This is probably why SWT [eclipse.org] came about (in part thanks to IBM).
The first application to use SWT, Eclipse, doesn't feel like a java application because it's using native widgets, which gives the GUI a very snappy response.
If the only strong reason you have avoided programming applications in Java is because of their slow GUI response, I suggest looking into SWT. =)
Re: Java eh? (Score:1, Informative)
"An Empirical Comparison of Programming Languages
Lutz Prechelt, An Empirical Comparison of C, C++, Java, Perl, Python, Rexx, and Tcl.
80 implementations of the same set of requirements are compared for several properties, such as runtime, memory consumption, source text length, comment density, program structure, reliability, and the amount of time required for writing them. The results indicate that, for the given programming problem, which regards string manipulation and search in a dictionary, "scripting languages" (Perl, Python, Rexx, Tcl) are more productive than "conventional languages". In terms of run time and memory consumption, they often turn out better than Java and not much worse than C or C++. In general, the differences between languages tend to be smaller than the typical differences due to different programmers within the same language."
Re:Real URL to image (Score:3, Informative)
IE ignores the MIME type provided it by the server, in violation of RFC 1945 and RFC 2616 ("Hypertext Transfer Protocol -- HTTP/1.0" and "...-- HTTP/1.1") sections 7.2.1 (reprinted below from the latter), and instead sniffs the content to determine how to render it. Anything served as "text/plain" is treated with suspicion and reinterpreted by IE in violation of this section. Microsoft breaks this in that they don't understand what "if and only if" means (i.e. the client MUST NOT guess media type by inspection when any type IS provided by the server).
While this makes their browser work with misconfigured servers that fail to set types correctly, the habit of testing with that and only that browser effectively hides the problem from authors and breaks pages for every browser that follows the RFC.
As this is seen as a benefit for IE over other browsers, Microsoft is uninterested in fixing it. Compare Netscape's unclosed quoted attribute bug which broke other browsers and which Netscape did fix, but then made previously working pages require fixing.
Please test your pages with standards-compliant browsers, including HTTP standards, and fix the problem with the server by assigning the appropriate file extension mapping of ".GIF" to "image/gif" on your server. (And every other case variation while you're at it.) Or rename the file to have a
Re:But HotSpot compiles and RECOMPILES on the fly (Score:3, Informative)
I don't think HotSpot takes nearly as much resources as people think it does, and gains quite a bit with (seemingly) simple optimizations.
Sun (am probably others) also have a statistical optimizer for their compilers. You compile it, run it with statitics on, then recompile against those stats. It will generate an optimized executable base on the stats.
Re:There are better ways of doing this (Score:4, Informative)
By the way, I'm going out on a limb here, but I have a feeling that someone who's been published in SIGGRAPH (THE graphics conference) is aware of the state of rendering algorithms in general, and of the existence of photon mapping in particular. Just a guess.
Re:There are better ways of doing this (Score:2, Informative)
Re:Java eh? (Score:5, Informative)
Given that this was an exercise, I'm somewhat tempted to ask whether you aren't counting the JVM startup time on top of a very short problem instance.
C: 30 seconds, Java: 8 hours. No kidding. These were running on the same laboratory machines, the Java programs using the latest Sun JVM at the time. The exercise involved calculating some statistics from a simulation run for one virtual year. Most of the people doing the Java version had to leave it running overnight. Besides, JVM startup time is a performance issue, you can't just dismiss it out of hand.
That, or whether the exercise involved lots of dynamic creation of objects (in which case your program was by definition not doing the same thing as the Java implementations). The exercise you mention sort of sounds like that.
In the Java version, each event was an object. In C each event was a malloc'd struct. These are analagous in that they are the correct way to solve the problem in that particular language. The fact that object creation and destruction is a lengthy process is an important reason why Java is so slow. It's an object-oriented language, its raison d'etre is to create and destroy objects. If it can't do that fast enough then what's the point in it being able to do anything else with speed?
I know at this point the Java apologists will say "just use a pool of pre-created Objects, that'll speed it up". This misses the point in two ways: (1) Java was supposed to obviate the need to perform manual memory handling. Now I have to not only remember to de-allocate my objects when I am done with them, I have to write a Pool class within which to store my not-currently-in-use objects?! (2) I can do that in C, too, if I really want to, and it'll make the C version faster again.
I am well aware of the forte of Haskell and its different interpreter implementations. To the degree that I wouldn't be surprised if the Haskell implementation did better than your C implementation.
They didn't. I was told they took around 10 minutes to run, but I never actually saw them working. When I produced results from a simulation that ran for 1000 years (an overnight run for my C program), the professor was amazed. But yes, in my experience interpreted Haskell is very fast, which makes Java look even more foolish.
I've done this four times now; written a C equivalent of a Java program and found it at least one, often several orders of magnitude faster. I've yet once to be shown a Java program that is significantly faster than its C equivalent.
This does not mean that Java should not be used as a programming language. The language features (especially those in version 1.5) are useful for working in a collaborative environment with mediocre programmers, and where the raw performance of the application is not critical (such as a GUI front-end to a server application). Just don't bullshit about it being faster than C, or even "fast" and expect me to believe it.
I'm willing to be proven wrong, but until someone can actually show me proof that it can be done, I'm not going to believe the hype, hand-waving and hot air.
Re:Java eh? (Score:3, Informative)
[* is there any other kind?
Re:Explain picture (Score:1, Informative)
This gives the simple raytraced scene that you are probably thinking of.
What are missing are diffuse rays: light from other objects that aren't lights and aren't in the direction of a mirror bounce. Gathering all the light is known as the global illumination problem.
There's lots of way to handle this including radiosity patches and monte carlo ray tracing.
It looks like this guy is doing some type of monte carlo ray tracing while properly taking into account wavelengths (i.e. not RGB but lamba) and many bounces instead of just direct or only X levels. He may also be tracing from the light out instead of the camera back.
I'm not sure if he's doing any stratified sampling or bundling of photons but it would help speed things up if he's not.
Swampped by email (Score:2, Informative)