9 Commits
v0.3 ... v0.4

Author SHA1 Message Date
a9019291c2 New goal for v0.4 2016-12-13 17:51:48 +01:00
5aa0b333c0 Made a fix, because previously it was not measuring primes. 2016-12-13 16:32:10 +01:00
3110c74174 Added entry about `restrict' keyword. 2016-12-13 16:12:31 +01:00
a5ce845c68 `restrict' keyword must be in declaration. 2016-12-13 16:12:03 +01:00
449fef2994 Add restrict
Add restrict for better pointer optimizations. This is not being applied
to `addToList()' because that function we want to thread later on.
2016-12-13 11:26:12 +01:00
2e9326b5fb Preparing for v0.4
I'm going to be learning OpenCL, after which I will decide whether to
use OpenCL or OpenMP for the development of Indivisible. This mostly
depends on the compatibility of each library with GMP, especially since
I believe GMP already does some of its own threading.
2016-12-12 23:21:22 +01:00
06cb271dba Forgot to set that shit to v0.3 2016-12-12 16:20:21 +01:00
4cbc3fae7d Cache the right .o files. 2016-12-10 17:43:31 +01:00
9b4fa96474 Remove TODO list. 2016-12-10 17:41:40 +01:00
6 changed files with 11 additions and 23 deletions

View File

@ -17,4 +17,4 @@ build:
# Cache .o files for faster compiling
cache:
paths:
- "*.o"
- "build/CMakeFiles/indivisible.dir/src/*.o"

View File

@ -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
View File

@ -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).

View File

@ -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]);
}

View File

@ -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.

View File

@ -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;