Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
a9019291c2 | |||
5aa0b333c0 | |||
3110c74174 | |||
a5ce845c68 | |||
449fef2994 | |||
2e9326b5fb | |||
06cb271dba | |||
4cbc3fae7d | |||
9b4fa96474 |
@ -17,4 +17,4 @@ build:
|
||||
# Cache .o files for faster compiling
|
||||
cache:
|
||||
paths:
|
||||
- "*.o"
|
||||
- "build/CMakeFiles/indivisible.dir/src/*.o"
|
||||
|
@ -16,3 +16,6 @@ Change Log
|
||||
- Algorithm skips half the known primes.
|
||||
- Removed `likely()' and `unlikely()' macros due to lack of information.
|
||||
- Improved performance.
|
||||
- v0.4: Fixed Algorithm
|
||||
- Fixed algorithm to actually calculate primes.
|
||||
- Added extra C99 optimizations.
|
||||
|
15
TODO.md
15
TODO.md
@ -1,15 +0,0 @@
|
||||
To-Do
|
||||
=====
|
||||
A to-do list for the project. Feel free to remove items as you solve them in your pull requests.
|
||||
|
||||
Next
|
||||
----
|
||||
To-do items to do for the next version:
|
||||
|
||||
- Profile code to better use `likely()` and `unlikely()` macros.
|
||||
|
||||
Features
|
||||
--------
|
||||
Features for future versions (not _Next_) of Indivisible:
|
||||
|
||||
- Implement multi-threaded version using OpenCL or OpenMP (whichever works).
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
#define BLOCK_SIZE 1024
|
||||
|
||||
void initList(List *l) {
|
||||
void initList(List *restrict l) {
|
||||
l->list = malloc(sizeof(mpz_t) * BLOCK_SIZE);
|
||||
if(!l->list) {
|
||||
fprintf(stderr, "Failed to allocate memory to list!\n");
|
||||
@ -18,7 +18,7 @@ void initList(List *l) {
|
||||
l->end = 0;
|
||||
}
|
||||
|
||||
void deInitList(List *l) {
|
||||
void deInitList(List *restrict l) {
|
||||
for(ulli i = 0; i < l->size; ++i) {
|
||||
mpz_clear(l->list[i]);
|
||||
}
|
||||
|
@ -20,14 +20,14 @@ typedef struct {
|
||||
* failure.
|
||||
* @param[in] l A pointer to a List type to be initialized.
|
||||
*/
|
||||
void initList(List *l);
|
||||
void initList(List *restrict l);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize a List.
|
||||
* @details Release all memory that has been allocated to the list.
|
||||
* @param[in] l A pointer to a List type to be deinitialized.
|
||||
*/
|
||||
void deInitList(List *l);
|
||||
void deInitList(List *restrict l);
|
||||
|
||||
/**
|
||||
* @brief Adds a new item to a List type.
|
||||
|
@ -11,7 +11,7 @@ static bool run;
|
||||
void leave();
|
||||
|
||||
int main(void) {
|
||||
puts("Indivisible v0.2\n");
|
||||
puts("Indivisible v0.4\n");
|
||||
|
||||
// Quit on ^C by setting `run = false'
|
||||
run = true;
|
||||
@ -43,8 +43,8 @@ int main(void) {
|
||||
// Calculate half of `num'
|
||||
mpz_fdiv_q_ui(halfNum, num, 2);
|
||||
// Loop through found primes
|
||||
// Skip 2 because we're skipping even nymbers
|
||||
for(ulli i = 1; mpz_cmp(primes.list[i], halfNum) >= 0; ++i) {
|
||||
for(ulli i = 0; i < primes.end; ++i) {
|
||||
if(mpz_cmp(primes.list[i], halfNum) >= 0) break;
|
||||
// If `num' is divisible by a prime then go to the next number
|
||||
if(mpz_divisible_p(num, primes.list[i]) != 0)
|
||||
goto nextPrime;
|
||||
|
Reference in New Issue
Block a user