Different implementations of a simple Collatz iterator and their performance

From ScienceZero
Revision as of 22:23, 2 January 2009 by Bjoern (Talk | contribs)

Jump to: navigation, search

The Collatz conjecture was proposed by Lothar Collatz in 1937. The conjecture is also known as the 3n + 1 conjecture.

The procedure is that if n is divisible by two then divide by two, else multiply by 3 and add 1, iterate until n reaches 1. The unproven conjecture is that for all values of n the procedure will always reach 1.

The benchmark times the iteration of the 226 first values of n.

Visual C++

Vista 64, 2.4 GHz core 2 Q6600

22.1s C++ 64 bit exe, one thread, unrolled 1000x 30.5s C++ 64 bit exe, one thread, unrolled 10x 45.9s C++ 32 bit exe, one thread, unrolled 1000x 49.2s C++ 64 bit exe, one thread, not unrolled 53.3s C++ 32 bit exe, one thread, unrolled 10x 76.1s C++ 32 bit exe, one thread, not unrolled

Vista 32, 2.66 GHz core 2 E66750

41.3 C++ 32 bit exe, one thread, unrolled 1000x 47.7 C++ 32 bit exe, one thread, unrolled 10x

Visual Basic 2008

Vista 64, 2.4 GHz core 2 Q6600

55.4s VB .net exe, one thread

Vista 32, 2.66 GHz core 2 E66750

66.4 VB .net exe, one thread

x86 assembly language

CUDA

1.625 GHz GTS 512,

2.3s CUDA 128 blocks x 256 threads

BSGP

External links