Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Discussions / General Discussions / Re: Simple JNI task on: 2004-01-29 14:42:34
stdin and stdout can be read from and written to using and System.out so I wouldn't bother trying to do this in native code.

The executable file will be called from an external program, that will communicate with it through stdin/out, so I haven't the option to use System.out/in! To be specific, I'm going to write a UCI (universal chess interface) for my chess engine.

To write to stdout in C++ one uses "cout >> ..." isn't it? To read from it "cin", but when do I know when new data is available? How to convert to a Java string?

For a C++/JNI expert this should be piece of cake to answer. Please post some code. Thanks!

2  Discussions / General Discussions / Simple JNI task on: 2004-01-28 00:40:25
Hi there,

I have to write a native executable, that first starts my java program and then continously transfers it all input recived from stdin and writes output from the Java program to stdout. Can anyone please show me how to do this (platform-independently) with VisualC++ or gcc?

Ideally there would be two methods in the Java code, one for writing a String and one to accept a String. I'm a complete Newbie in C/C++ and JNI. Are there any pitfalls?

Thanks a lot!
3  Game Development / Performance Tuning / Re: Array access pretty slow on: 2004-01-20 22:36:32
Oh, that was a lighning fast reply Shocked

No, unfortunately i can't (or at least it would be very messy) implement the stack with recursion.

Another question: generally what is faster, 2 accesses to arrays with length 64 or 1 access to an array with 4096 length? I suppose this depends on CPU caching... so it's platform dependant... a rule of thumb?

Have a nice day!
4  Game Development / Performance Tuning / Array access pretty slow on: 2004-01-20 21:45:31
Lastly I tried an optimization in a frequently executed piece of code: 3 variables of small size needed to be saved in a sort of "stack array" of fixed size. In the first version each variable was stored and retrieved from an individual array.

After packing all info into one single array with shifting and oring (saving two array acceses), the code was significantly faster! Obviously array access is much more expensive than a few bit-ops...

But how expensive is it really? I would guess it takes at least two condition checks for the bounds and one multiplication to calculate the address. Does anyone know exactly?

5  Game Development / Performance Tuning / Re: Find out how many CPUs a system has on: 2004-01-10 13:48:39
Thanks, that will be optimal. Strange they added this functionality so late...

An other question comes to my mind. What about this new hyperthreading technology of intels P4 (I read of a 25% performance increase): will a multithreaded java application benefit from it? If that's true, I should use the parallel algorithm with two threads even on a single processor system, hmm... how to detect a hyperthreading processor?
6  Game Development / Performance Tuning / Find out how many CPUs a system has on: 2004-01-10 04:27:33
In my application I need to find out how many processors the host system has, in order to start an appropriate numer of threads (in my case numberOfThreads = numberOfCPUs). Is there a standard means of achieving this in Java? If not, can anyone please give me a hint how to do this platform-independantly with JNI... (I never used native code, so please explain this in a fool-proof manner) Thanks a lot!
7  Game Development / Performance Tuning / Unreachable code removal on: 2004-01-08 01:59:36
When a block of code is unreachable at compile time, will the compiler remove it? Example:

final boolean DO_THAT = false;

if (DO_THAT) {
 // code...

In my application I'm specially interested in the removal of the condition check, since the condition will always be true or false at compile time.
8  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-11 22:31:18
Thanks a lot for your help. So basically bitIndex2() seems to be the right thing to do - just not in the fastest variant. Originally I hoped that maybe someone would come up with a better algorithm, maybe exploiting some obscure bit fumbling.

Because my work is in the early stages I'll consider switching to C/C++ and later optimize with assembly. Could be quite fun and challenging - maybe I'll toast my CPU  Roll Eyes I wonder how a C++ and then an asm version would compare in terms of cycles.

Can it be true, that Sun 1.2 is faster than the successor VMs? Strange...

Merry Christmas & Happy new Year
9  Game Development / Performance Tuning / Finding index of single 1 bit in a long on: 2003-12-09 14:14:56
Hi everybody. I'm working on a chess program which makes frequent calls to a method, that finds the position of the first (and only) set bit in a long value. So for 1->0, 2->1, 4->2, 8->3, 16->4, ...

The straight-foward code is this:

 public static int bitIndex1(long x) {
   int r = 0;
   while ((x & (1L << r)) == 0)
   return r;

The enhanced version takes less time in the average case:

 public static int bitIndex2(long x) {
   int r = 0;
   if ((x & 0xFFFFFFFF00000000L) != 0) r += 32;
   if ((x & 0xFFFF0000FFFF0000L) != 0) r += 16;
   if ((x & 0xFF00FF00FF00FF00L) != 0) r += 8;
   if ((x & 0xF0F0F0F0F0F0F0F0L) != 0) r += 4;
   if ((x & 0xCCCCCCCCCCCCCCCCL) != 0) r += 2;
   if ((x & 0xAAAAAAAAAAAAAAAAL) != 0) r++;
   return r;

Is it possible to do this even faster? On x86 there is a single assembly instruction which does this kind of stuff Sad
Pages: [1]
EgonOlsen (37 views)
2018-06-10 19:43:48

EgonOlsen (20 views)
2018-06-10 19:43:44

EgonOlsen (39 views)
2018-06-10 19:43:20

DesertCoockie (186 views)
2018-05-13 18:23:11

nelsongames (122 views)
2018-04-24 18:15:36

nelsongames (121 views)
2018-04-24 18:14:32

ivj94 (861 views)
2018-03-24 14:47:39

ivj94 (122 views)
2018-03-24 14:46:31

ivj94 (758 views)
2018-03-24 14:43:53

Solater (139 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!