/******************************************************************************\ * $Revision$ * * $Id$ * $Log$ * * 100billion.cpp * ============== * * This program is to measure the time taken to simulate one cycle of * 'computation' a complete human brain based on two broad and overly * simplistic assumptions: * 1) There are 100,000,000,000 neurons in the brain * 2) Each neuron connects to 1000 others * * Note: this number is too big to fit in a single unsigned long integer * and the decrement of 1 unit is too small to affect a float this size. * hence two longs are used * * Even with an empty UpdateNeuron function this takes about 8hrs to run on * an AMD K6-III 450MHz. * * Real timings on win98SE for high = 101: * gcc 100billion.cpp -lstdc++ -o100billion.exe -O4 9m03 --> 7 days for all * gcc 100billion.cpp -lstdc++ -o100billion.exe -O2 8m38 --> 7 days for all * gcc 100billion.cpp -lstdc++ -o100billion.exe 9m14 --> 7 days for all * \******************************************************************************/ #include #include //this would have to be 100 billion for a true simulation const unsigned long Neurons = 2; const unsigned long Connectivity = 1000; //connection stengths between neurons unsigned long Connections[Connectivity][Neurons]; //activations into a neuron unsigned long Activations[Connectivity]; // pretend to update a neuron void UpdateNeuron(void) { unsigned long WeightedSum = 0; // pretend to calculating a weighted sum // by means of looking up activations and connection strengths in // a table unsigned long J=1; for(unsigned long I=0;I!=Connectivity;I++) { WeightedSum += Connections[I][J] * Activations[I]; } // pretend to look up a value in a threshold function table WeightedSum %= 1000; WeightedSum = Activations[WeightedSum]; } // setup up a table pretending to be the inputs to a neuron void Setup(void) { for(unsigned long I=0;I!=Connectivity;I++) { Activations[I] = I; Connections[I][0] = Connectivity - I; Connections[I][1] = Connectivity - I; } }; int main(int argc,char** argv) { // establish a pretend table // the real ones would take more than 10^12 bytes of storage! Setup(); const unsigned long Million = 1000000; unsigned long High = 101; unsigned long Low = 1000000; // These are used to display purposes only unsigned long Tick = 0; unsigned long OutputTick = 1; time_t StartTime = time(NULL); do { UpdateNeuron(); if ((--Low) == 0) { High--; Low = Million; if ((Tick++) > OutputTick) { std::cout << "Updating Neurons: " << High << std::endl; Tick = 0; } } } while(High > 0); time_t TotalTime = time(NULL) - StartTime; struct tm* TotalTimeStruct = gmtime(&TotalTime); std::cout << "Total Time Elapsed: " << TotalTimeStruct->tm_hour << "h" << TotalTimeStruct->tm_min << "m" << TotalTimeStruct->tm_sec << "s" << std::endl; } //main /*******/ /* EOF */ /*******/