bool early_sleep = false;
double cpu_time = 20, comp_result;
*/
+/*
int QuickSortPartition(RainbowChainCP* pChain, int nLow, int nHigh)
{
- int nRandomIndex = nLow + ((unsigned int)rand() * (RAND_MAX + 1) + (unsigned int)rand()) % (nHigh - nLow + 1);
+ int nRandomIndex = nLow + ((uint32)rand() * ((uint32)RAND_MAX + 1) + (uint32)rand()) % (nHigh - nLow + 1);
RainbowChainCP TempChain;
TempChain = pChain[nLow];
pChain[nLow] = pChain[nRandomIndex];
QuickSort(pChain, nPivotLoc + 1, nHigh);
}
}
-
+*/
int main(int argc, char **argv) {
int retval;
double fd;
fprintf(stderr, "boinc_init returned %d\n", retval);
exit(retval);
}
-
-
- // get size of input file (used to compute fraction done)
- //
- //file_size(input_path, fsize);
-
- // See if there's a valid checkpoint file.
- // If so seek input file and truncate output file
- //
+ // extract a --device option
+ std::vector<char*> argVec;
+ int cudaDevice = -1;
+ for(int ii = 0; ii < argc; ii++) {
+ if(cudaDevice < 0 && strcmp(argv[ii], "--device") == 0 && ii + 1 < argc)
+ cudaDevice = atoi(argv[++ii]);
+ else
+ argVec.push_back(argv[ii]);
+ }
+ argc = (int)argVec.size();
+ argv = &argVec[0];
+ if(!(cudaDevice < 0))
+ // set the cuda device
+ if(rcuda::SetCudaDevice(cudaDevice) != 0)
+ {
+ //XXX this call doesn't work on linux
+ // fixed in upstream source 2010-09-16
+ // http://bolt.berkeley.edu/trac/changeset/22382
+ #ifdef _WIN32
+ boinc_temporary_exit(60);
+ #endif
+ }
if(argc < 10)
{
// Open file
-// fclose(fopen(sFilename.c_str(), "a"));
-// FILE* file = fopen(sFilename.c_str(), "r+b");
- boinc_resolve_filename("result", output_path, sizeof(output_path));
+ boinc_resolve_filename("result", output_path, sizeof(output_path));
fclose(boinc_fopen(output_path, "a"));
FILE *outfile = boinc_fopen(output_path, "r+b");
unsigned int nFileLen;
// Round to boundary
- nDataLen = nDataLen / 18 * 18;
- if ((int)nDataLen == nRainbowChainCount * 18)
+ nDataLen = nDataLen / 10 * 10;
+ if (nDataLen == nRainbowChainCount * 10)
{
std::cerr << "precomputation of this rainbow table already finished" << std::endl;
fclose(outfile);
}
fseek(outfile, nDataLen, SEEK_SET);
+ //XXX size_t isn't 32/64 clean
size_t nReturn;
CChainWalkContext cwc;
uint64 nIndex[2];
+ time_t tStart = time(NULL);
// std::cout << "Starting to generate chains" << std::endl;
- int maxCalcBuffSize = rcuda::GetChainsBufferSize(5000);
+ int maxCalcBuffSize = rcuda::GetChainsBufferSize(0x2000);
uint64 *calcBuff = new uint64[2*maxCalcBuffSize];
int ii;
rcuda::RCudaTask cuTask;
std::vector<unsigned char> stPlain;
ex.Init();
-time_t tStart, tStartFinal, tEndFinal;
-time_t tEnd;
- tStartFinal = time(NULL);
- for(int nCurrentCalculatedChains = nDataLen / 18, calcSize; nCurrentCalculatedChains < nRainbowChainCount; )
+
+ for(int nCurrentCalculatedChains = nDataLen / 10, calcSize; nCurrentCalculatedChains < nRainbowChainCount; )
{
fd = (double)nCurrentCalculatedChains / (double)nRainbowChainCount;
boinc_fraction_done(fd);
cuTask.reduceOffset = ex.GetReduceOffset();
cuTask.plainSpaceTotal = ex.GetPlainSpaceTotal();
cuTask.rainbowChainLen = nRainbowChainLen;
- for(int ii = 0; ii < cuTask.idxCount; ii++) {
+ for(ii = 0; ii < cuTask.idxCount; ii++) {
calcBuff[2*ii] = cuTask.startIdx + ii;
calcBuff[2*ii+1] = 0;
}
-
- tStart = time(NULL);
-
calcSize = rcuda::CalcChainsOnCUDA(&cuTask, calcBuff);
- tEnd = time(NULL);
- std::cerr << "CUDA time taken: " << tEnd - tStart << std::endl;
- tStart = time(NULL);
+
if(calcSize > 0) {
nCurrentCalculatedChains += calcSize;
for(ii = 0; ii < cuTask.idxCount; ii++) {
nIndex[0] = cuTask.startIdx + ii;
- nReturn = fwrite(nIndex, 1, 8, outfile);
- nReturn += fwrite(calcBuff+(2*ii), 1, 8, outfile);
+// nReturn = fwrite(nIndex, 1, 8, outfile);
+ nReturn = fwrite(calcBuff+(2*ii), 1, 8, outfile);
nReturn += fwrite(calcBuff+(2*ii+1), 1, 2, outfile);
- if(nReturn != 18) {
+ if(nReturn != 10) {
std::cerr << "disk write fail" << std::endl;
fclose(outfile);
return 9;
return 0;
}
}
- tEndFinal = time(NULL);
- std::cerr << "Time taken: " << tEndFinal - tStartFinal << " secs" << std::endl;
delete [] calcBuff;
#ifdef _DEBUG
std::cout << "Generation completed" << std::endl;
#endif
+/*
fseek(outfile, 0, SEEK_SET);
nFileLen = GetFileLen(outfile);
nRainbowChainCount = nFileLen / 18;
std::cout << "Sorting file" << std::endl;
#endif
fseek(outfile, 0, SEEK_SET);
- for(int i = 0; i < nRainbowChainCount; i++)
+ for(uint32 i = 0; i < nRainbowChainCount; i++)
{
if(fread(&pChain[i], 1, 16, outfile) != 16)
{
// Write file
fseek(outfile, 0, SEEK_SET);
- for(int i = 0; i < nRainbowChainCount; i++)
+ for(uint32 i = 0; i < nRainbowChainCount; i++)
{
fwrite(&pChain[i], 1, 16, outfile);
fwrite(&pChain[i].nCheckPoint, 2, 1, outfile);
}
delete[] pChain;
}
-
+*/
fclose(outfile);
// main loop - read characters, convert to UC, write
return main(argc, argv);
}
#endif
-
-const char *BOINC_RCSID_33ac47a071 = "$Id: upper_case.C 12135 2007-02-21 20:04:14Z davea $";
-