https://www.hackerrank.com/challenges/the-grid-search
$ cc -O2 -o c main.c
$ go build -o go main.go
$ time ./c < z.txt
https://www.hackerrank.com/challenges/the-grid-search
$ cc -O2 -o c main.c
$ go build -o go main.go
$ time ./c < z.txt
package main | |
import ( | |
"fmt" | |
"os" | |
"unicode/utf16" | |
) | |
/* | |
#include <Windows.h> |
There are three result files:
results-for-original: Results for the orignal benchmark
results-for-modified: Resutls for a modified benchmark (see hello.go in this gist)
results-for-modified2: Results for a modified benchmark (same as 2 but where MaxConnectionCount=100)
There appears to be a problem with the way the DCPU rc1 does DIV. The current DCPU RC1 implementation does the following for DIV:
long val = (b << 16) / a;
b = (char)(int)(val >> 16);
this.ex = (char)(int)val;
Given b = 0xFFFF, a = 0x2 the result will be a = 0xFFFF and ex = 0x8000. This is wrong. (0xFFFF << 16) / 0x2 should = 0x7FFF8000. The problem is that given "(b << 16) / a", Java will sign extend it. So, what Java ends up doing is (0xFFFFFFFFFFFF0000 / 0x2) which produces 0xFFFFFFFFFFFF8000 and that's not what is described in the spec. In order for the DCPU to meet the spec it would need to do:
The Universal Spaceship Bus is a time division multiplexed ship wide communications | |
medium. On startup each device is assigned an address by the bus master. The bus master | |
cycles through each device in turn asking it if it has a message to send. If the device | |
has a message to send, the buss master will obtain the destination address from the source | |
and then ask the destination device if it is ready to receive a message, if yes, then the | |
bus master will transfer the message from source to destination. If the destination device | |
isn't ready, the bus master will move on to the next device on the bus. | |
The exchange looks like this: |