inline BigInt FindFactor ( const BigInt& n, const PollardPMinusOneCtrl<SieveUnsigned>& ctrl ) { DynamicSieve<SieveUnsigned> sieve; return FindFactor( n, sieve, ctrl ); }
inline Grid::Grid( mpi::Comm comm, GridOrder order ) : haveViewers_(false), order_(order) { DEBUG_ONLY(CallStackEntry cse("Grid::Grid")) // Extract our rank, the underlying group, and the number of processes mpi::Dup( comm, viewingComm_ ); mpi::CommGroup( viewingComm_, viewingGroup_ ); size_ = mpi::Size( viewingComm_ ); // All processes own the grid, so we have to trivially split viewingGroup_ owningGroup_ = viewingGroup_; // Factor p height_ = FindFactor( size_ ); SetUpGrid(); }
EXPORT void* _primeFactors(S64 n) { IntList* top = NULL; IntList* bottom = NULL; int num = 0; while (n > 1) { S64 factor = FindFactor(n, 1); IntList* node = (IntList*)AllocMem(sizeof(IntList)); node->Value = factor; node->Next = NULL; if (top == NULL) { top = node; bottom = node; } else { bottom->Next = node; bottom = node; } num++; n /= factor; } U8* result = (U8*)AllocMem(0x10 + sizeof(S64) * (size_t)num); ((S64*)result)[0] = DefaultRefCntFunc; ((S64*)result)[1] = (S64)num; { IntList* ptr = top; S64* dst = (S64*)result + 2; while (ptr != NULL) { IntList* ptr2 = ptr; ptr = ptr->Next; *dst = ptr2->Value; dst++; FreeMem(ptr2); } } qsort((S64*)result + 2, (size_t)num, sizeof(S64), CmpInt); return result; }
inline Grid::Grid( mpi::Comm comm ) { DEBUG_ONLY(CallStackEntry cse("Grid::Grid")) inGrid_ = true; // this is true by assumption for this constructor // Extract our rank, the underlying group, and the number of processes mpi::CommDup( comm, viewingComm_ ); mpi::CommGroup( viewingComm_, viewingGroup_ ); viewingRank_ = mpi::CommRank( viewingComm_ ); size_ = mpi::CommSize( viewingComm_ ); // All processes own the grid, so we have to trivially split viewingGroup_ owningGroup_ = viewingGroup_; notOwningGroup_ = mpi::GROUP_EMPTY; owningRank_ = viewingRank_; // Factor p height_ = FindFactor( size_ ); width_ = size_ / height_; SetUpGrid(); }