From 4713dd7bb0e56041fd477a2c382f8a016a9d7359 Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Sat, 22 May 2021 12:38:29 +0200 Subject: [PATCH 01/14] Guidelines based on specification of characteristics/labels --- CONTRIBUTING.md | 272 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 212 insertions(+), 60 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ed0c87f18..43c2a0c30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,9 +7,8 @@ These guidelines have been drafted to facilitate a "fair" comparison between sol ## Guide -### Determining the category/categories -Once you've written the solution, make a determination on whether it is faithful to the original implementation, and whether it is parallel or not. -You can do this by referring to [the category descriptions](#Categories) mentioned below. +### Determining the implementation characteristics +Once you've written the solution, make sure it complies with the basic [rules](#rules) and determine what are the relevant characteristics of your implementation(s). You can do this by referring to [the descriptions of relevant characteristics](#characteristics) included below. ### README.md Now make sure to add a `README.md` that contains at least the following: @@ -17,7 +16,7 @@ Now make sure to add a `README.md` that contains at least the following: ``` # solution by - +(Optional) *Give a short description of your implementation* @@ -30,14 +29,14 @@ Now make sure to add a `README.md` that contains at least the following: *Show the output you got on your machine(s) here, in code blocks* ``` -Concerning the category badge(s): -* The category badges for the various categories are specified in [their respective sections](#Categories). -* If your solution includes multiple implementations that fall under different categories, include one category badge for each category. -* If your solution deviates from the basic [rules](#Rules), add an additional category badge, using the following template: +With the introduction of labels in the [output format](#output), badges are now optional in the `README.md` _if labels are used in the solution output_. If you do choose to add badges to your `README.md`, then: +* They need to comply with what is described in [the characteristics section](#characteristics). +* If your solution includes multiple implementations that have different characteristics, then add all appropriate badges, once. +* If your solution deviates from the basic [rules](#rules), add an additional badge, using the following template: ``` - ![Category](https://img.shields.io/badge/Category--blue) + ![Deviation](https://img.shields.io/badge/Deviation--blue) ``` - Choose an appropriate name, and include an explanation in your README.md. + Choose an appropriate name, and include an explanation in your `README.md`. ### Folder/directory In the `drag-race` branch, see what the highest numbered solution is for the language you chose, and place your solution in the following folder: @@ -46,7 +45,7 @@ In the `drag-race` branch, see what the highest numbered solution is for the la If no solution yet exists for the language you're submitting, put yours in `Prime/solution_1/` ### Dockerfile -Please add a `Dockerfile` that is configured to build and run your solution. It should output the run result to standard output (stdout), using the format specified in the basic [rules](#Rules). Any "auxiliary" output should be directed to standard error (stderr), if the language and toolkit you chose allows. +Please add a `Dockerfile` that is configured to build and run your solution. It should output the run result to standard output (stdout), using the format described under [output](#output). As indicated there, any "auxiliary" output should be directed to standard error (stderr), if the language and toolkit you chose allows. When composing the Dockerfile, please use the following as a reference for selecting the base image: * If an official image exists on [Docker Hub](https://hub.docker.com/) for the language you chose, use that. If multiple images are available with different underlying Linux distributions, select the one to use in accordance with the next steps in this list. @@ -67,74 +66,227 @@ Finally, submit a pull request **targeting the branch `drag-race`**, and place a If you need assistance with conforming to any of the guidelines mentioned above, then please clearly indicate this in your pull request and be specific in what you need help with. Note that we cannot guarantee that we can help make your solution mergeable if it doesn't conform to the guidelines, but we will do our best to help where we can. -## Categories +## Rules -### Faithful +* Your solution uses the sieve of Erastosthenes. +* Your benchmarked code returns either a list of primes or the `is_prime` array, containing the result of the sieve. +* Your solution runs for at least 5 seconds, and stops as quickly as possible after that. +* Your solution calculates all the primes up to 1,000,000. +* You own copyright to all code and are willing to license that code under BSD-3 or compatible, or the code is available under BSD-3 or compatible. -#### Requirements: +## Characteristics -* Your solution uses no external dependencies to calculate the actual sieve. -* Your solution uses a class to encapsulate the sieve, or an equivalent feature in your language. This class must contain the full state of the sieve. Each iteration should re-create a new instance of this class. -* Your solution does not use multi-threading or multi-processing. -* Your solution conforms to the base [rules](#Rules). +The collection of solutions in this repository have come to use different approaches to implementing the prime number sieve. A number of characteristics have been defined as being relevant for an equal comparison between implementations. These are: +| Name | Description | +|-|-| +| [algorithm](#algorithm) | The algorithm used to find the primes in the prime number sieve. | +| [faithfulness](#faitfhulness) | If the implementation is true to the original one implemented by @davepl, at a technical level. | +| [parallelism](#parallelism) | If the implementation uses any type of multi-threaded processing/calculation. | +| [storage](#flag-storage) | The number of bits used to indicate if a number in the sieve is a prime number, or not. | -#### Category badge: +
-![Category](https://img.shields.io/badge/Category-faithful-green) +These characteristics are discussed in more detail in the following sections. -#### Category badge markdown: +### Algorithm -``` -![Category](https://img.shields.io/badge/Category-faithful-green) -``` +This defines the algorithm(s) used by your implementation(s). -### Parallel faithful +#### Known algorithms -#### Requirements: +We currently consider the following algorithms to be "known" algorithms: +| Name | Description | +|-|-| +| base | This is the algorithm that was used by @davepl in the YouTube video that spawned this repository. It is described in more detail, [below](#base-algorithm). | +| wheel | Algorithms rooted in the principle of [wheel factorization](https://en.wikipedia.org/wiki/Wheel_factorization). These tend to translate to having a (pre)calculated set of prime numbers within a certain base number range, that are then sequentially projected onto the sieve. | +| **other** | All algorithms that do not fall in the values already mentioned. This is used as the default if no algorithm is specified. | -* Your solution uses no external dependencies to calculate the actual sieve (for example, `-lpthread` is fine). -* Your solution uses a class to encapsulate the sieve, or an equivalent feature in your language. This class must contain the full state of the sieve. Each iteration should re-create a new instance of this class. -* Your solution conforms to the base [rules](#Rules). +
-#### Category badge: +**Note:** All implementations **must** use a form of [the Sieve of Erastosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) as the fundamental algorithm, as indicated in the basic [rules](#rules). -![Category](https://img.shields.io/badge/Category-faithful%2Cparallel-green) +#### Base algorithm -#### Category badge markdown: +The base algorithm is defined as follows: +* The algorithm uses an outer loop, in which two operations are performed: + 1. searching for the next prime in the sieve, and + 2. clearing this prime's multiples in the sieve. + + In order to allow for idiomatic code, it is permissible to perform these steps in either order, provided the results are correct. -``` -![Category](https://img.shields.io/badge/Category-faithful%2Cparallel-green) -``` +* When seeking factors (the first operation), the algorithm sequentially checks all odd numbers, starting at 3. -### Unfaithful +* When clearing non-primes in the sieve (the second operation), the algorithm clears all non-primes individually, increasing the number with 2 * factor on each cycle. -#### Requirements: -* Your solution is not faithful, but conforms to the base [rules](#Rules). +* Not seeking factors beyond the square root of the sieve size is permissible. -#### Category badge: +* Inverted prime marking logic (marking primes as zero/false and non-primes as one/true) is permissible. -![Category](https://img.shields.io/badge/Category-unfaithful-yellowgreen) +* Starting the clearing loop at factor * factor (instead of 3 * factor, as done in the original implementation) is permissible. -#### Category badge markdown: +If needed, the [original implementation in C++](https://github.com/PlummersSoftwareLLC/Primes/blob/drag-race/PrimeCPP/solution_1/PrimeCPP.cpp) can be used as a reference. -``` -![Category](https://img.shields.io/badge/Category-unfaithful-yellowgreen) -``` +#### Label -## Rules +The [output label](#output) for the algorithm is `algorithm`. Recognized values are those listed under [known algorithms](#known-algorithms). If an implementation doesn't write an `algorithm` label to output, it is considered to be an `other` algorithm. -* Your solution uses the sieve of Erastosthenes. -* Your benchmarked code returns either a list of primes or the `is_prime` array, containing the result of the sieve. -* Your solution runs for at least 5 seconds, and stops as quickly as possible after that. -* Your solution calculates all the primes up to 1,000,000. -* The test code outputs the following text to standard output: - ``` - ;;; - ``` - where: - * `name` is **at least** your username, and if you have multiple implementations, a short keyword to discriminate each implementation - * `iterations` is the amount of times your code ran in the allotted time - * `total_time` is the total time it took to run, which would be slightly more than 5 seconds, in an `en_US` formatted decimal value (so, use `.` (period) and not `,` (comma) as the decimal separator) - * `num_threads` is the total amount of threads that were used to execute the indicated number of `iterations`(so 1 for a single-threaded solution) -* Your solution adheres to the requirements of the category/categories you put it under. -* You own copyright to all code and are willing to license that code under BSD-3 or compatible, or the code is available under BSD-3 or compatible. +#### Badge + +If you choose to include badges in your `README.md`, then: +* if the base algorithm is used, the badge to use is: + + ![Algorithm](https://img.shields.io/badge/Algorithm-base-green) + + The corresponding markdown is: + + ``` + ![Algorithm](https://img.shields.io/badge/Algorithm-base-green) + ``` + +* if a different algorithm is used (either wheel or other), then the badge template to use is: + + ![Algorithm](https://img.shields.io/badge/Algorithm--yellowgreen) + + The corresponding markdown is: + + ``` + ![Algorithm](https://img.shields.io/badge/Algorithm--yellowgreen) + ``` + +### Faithfulness + +At a technical level, an implementation is considered faithful if it complies with the following: + +* It uses no external dependencies to calculate the actual sieve. +* It uses a class to encapsulate the sieve, or an equivalent feature in your language. This class must contain the full state of the sieve. Each iteration should re-create a new instance of this class. +* It conforms to the base [rules](#Rules). + +All other implementations are considered unfaithful. Note that they still need to conform to the base [rules](#Rules). + +If the faithfulness of an implementation is not specified, it is assumed to be unfaithful. + +#### Label + +The [output label](#output) to express faithfulness is `faithful`. Recognized values are `yes` for faithful implementations, and `no` for unfaithful implementations. If an implementation doesn't write a `faithful` label to output, it is considered to be an unfaithful algorithm. + +#### Badge + +If you choose to include badges in your `README.md`, then: +* if the implementation is faithful, the badge to use is: + + ![Faithfulness](https://img.shields.io/badge/Faithful-yes-green) + + The corresponding markdown is: + + ``` + ![Faithfulness](https://img.shields.io/badge/Faithful-yes-green) + ``` + +* if the implementation is unfaithful, the badge to use is: + + ![Faithfulness](https://img.shields.io/badge/Faithful-no-yellowgreen) + + The corresponding markdown is: + + ``` + ![Faithfulness](https://img.shields.io/badge/Faithful-no-yellowgreen) + ``` + +### Parallelism + +This indicates if the implementation uses any form of parallelism. In this context, an implementation is considered to do so if more than 1 thread is involved with running the sieve, i.e. identifying the primes in it. + +#### Label + +As the [output](#output) of implementations specify how many threads are used, it is not needed to use a label to specify if an implementation is multi-threaded. + +#### Badge + +If you choose to include badges in your `README.md`, then: +* if the implementation is single-threaded, the badge to use is: + + ![Parallelism](https://img.shields.io/badge/Parallel-no-green) + + The corresponding markdown is: + + ``` + ![Parallelism](https://img.shields.io/badge/Parallel-no-green) + ``` + +* if the implementation is multi-threaded, the badge to use is: + + ![Parallelism](https://img.shields.io/badge/Parallel-yes-green) + + The corresponding markdown is: + + ``` + ![Parallelism](https://img.shields.io/badge/Parallel-yes-green) + ``` + +### Flag storage + +This characteristic specifies how many bits the implementation uses to store the indication (flag) if a number in the sieve is a prime number, or not. + +Common bit counts are: +| Number | Used when | +|-|-| +| 1 | Each prime number flag occupies one bit. Common implementations of this type use a bit array or bit masking on wider data types to get and set individual flags. | +| 8 | Common implementations that occupy 8 bits per flag store the flags in a "byte" variable. | +| 32 | Common implementations that occupy 32 bits per flag store the flags in a "regular" integer variable. | +| 64 | Common implementations that occupy 32 bits per flag store the flags in a "long" integer variable. | + +
+ +It's possible that the number of bits per flag is unknown. For example, this can be the case if an implementation uses a "boolean" basic type provided by the language, and the language does not define how booleans are logically stored in memory. + +#### Label + +The [output label](#output) for the flag size is `bits`. The value should reflect the exact number of bits that are occupied by each prime number flag. If an implementation doesn't write a `bits` label to output, the bit count per label is considered to be unknown. + +#### Badge + +If you choose to include badges in your `README.md`, then: +* if the implementation's flag size is known to be 1 bit, the badge to use is: + + ![Bit count](https://img.shields.io/badge/Bits-1-green) + + The corresponding markdown is: + + ``` + ![Bit count](https://img.shields.io/badge/Bits-1-green) + ``` + +* if the implementation's flag size is known but larger than 1 bit, the badge template to use is: + + ![Bit count](https://img.shields.io/badge/Bits--yellowgreen) + + The corresponding markdown is: + + ``` + ![Bit count](https://img.shields.io/badge/Bits--yellowgreen) + ``` + +* if the implementation's flag size is unknown, the badge to use is: + + ![Bit count](https://img.shields.io/badge/Bits-unknown-yellowgreen) + + The corresponding markdown is: + + ``` + ![Bit count](https://img.shields.io/badge/Bits-unknown-yellowgreen) + ``` + +## Output + +Your solution should write the following text to standard output for each implementation that it runs: +``` +;;;; +``` +where: +* `name` is **at least** your username, and if you have multiple implementations for a specific language, a short keyword to discriminate each implementation. +* `iterations` is the amount of times your code ran in the allotted time. +* `total_time` is the total time it took to run, which would be slightly more than 5 seconds, in an `en_US` formatted decimal value (so, use `.` (period) and not `,` (comma) as the decimal separator). +* `num_threads` is the total amount of threads that were used to execute the indicated number of `iterations` (so 1 for a single-threaded solution). +* `labels` is an optional collection of key/value pairs that provide information on the [characteristics](#characteristics) of your implementation(s). If you don't output labels, then the semicolon (`;`) between `num_threads` and `labels` should also not be written. Do note that default values are used for all labels that are not included. + +Any other output should be directed to standard error, if possible. \ No newline at end of file From b40b68c6c5a9926434c6d0412fbf5c8fb3e5eb3f Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Sat, 22 May 2021 12:51:36 +0200 Subject: [PATCH 02/14] Improved explanation of label format --- CONTRIBUTING.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 43c2a0c30..276c128b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -287,6 +287,29 @@ where: * `iterations` is the amount of times your code ran in the allotted time. * `total_time` is the total time it took to run, which would be slightly more than 5 seconds, in an `en_US` formatted decimal value (so, use `.` (period) and not `,` (comma) as the decimal separator). * `num_threads` is the total amount of threads that were used to execute the indicated number of `iterations` (so 1 for a single-threaded solution). -* `labels` is an optional collection of key/value pairs that provide information on the [characteristics](#characteristics) of your implementation(s). If you don't output labels, then the semicolon (`;`) between `num_threads` and `labels` should also not be written. Do note that default values are used for all labels that are not included. +* `labels` is an optional collection of name/value pairs that provide information on the [characteristics](#characteristics) of your implementation(s). They are discussed in more detail, below. -Any other output should be directed to standard error, if possible. \ No newline at end of file +Any other output should be directed to standard error, if possible. + +### Labels + +If you choose to include labels, then: +* they must conform to what's indicated in the [characteristics](#characteristics) section. +* specificy each label as `=` +* If multiple lables are included in your output, separate them with commas (`,`). +* Don't use spaces between names, values, or name/value pairs +* If you don't output labels, then the semicolon (`;`) between `num_threads` and `labels` should also not be written. + +Do note that default values are used for all labels that are not included. + +### Examples + +An example of a line of output with labels is: +``` +rbergen;1234;5.005678;1;algorithm=base,faithful=no,bits=1 +``` + +A line of output without labels could look like this: +``` +rbergen;1234;5.005678;1 +``` From b2641245148cf4961061aa9f006a985bfc206fad Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Sat, 22 May 2021 12:59:31 +0200 Subject: [PATCH 03/14] Touched up post-table whitespace --- CONTRIBUTING.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 276c128b2..3c546a730 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,8 +84,6 @@ The collection of solutions in this repository have come to use different approa | [parallelism](#parallelism) | If the implementation uses any type of multi-threaded processing/calculation. | | [storage](#flag-storage) | The number of bits used to indicate if a number in the sieve is a prime number, or not. | -
- These characteristics are discussed in more detail in the following sections. ### Algorithm @@ -101,8 +99,6 @@ We currently consider the following algorithms to be "known" algorithms: | wheel | Algorithms rooted in the principle of [wheel factorization](https://en.wikipedia.org/wiki/Wheel_factorization). These tend to translate to having a (pre)calculated set of prime numbers within a certain base number range, that are then sequentially projected onto the sieve. | | **other** | All algorithms that do not fall in the values already mentioned. This is used as the default if no algorithm is specified. | -
- **Note:** All implementations **must** use a form of [the Sieve of Erastosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) as the fundamental algorithm, as indicated in the basic [rules](#rules). #### Base algorithm @@ -235,8 +231,6 @@ Common bit counts are: | 32 | Common implementations that occupy 32 bits per flag store the flags in a "regular" integer variable. | | 64 | Common implementations that occupy 32 bits per flag store the flags in a "long" integer variable. | -
- It's possible that the number of bits per flag is unknown. For example, this can be the case if an implementation uses a "boolean" basic type provided by the language, and the language does not define how booleans are logically stored in memory. #### Label From 2c6caea4c9c530afb337231a97dd65b2160d0fe3 Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Sat, 22 May 2021 13:21:16 +0200 Subject: [PATCH 04/14] Small refinements --- CONTRIBUTING.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c546a730..602146ef9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ Now make sure to add a `README.md` that contains at least the following: *Show the output you got on your machine(s) here, in code blocks* ``` -With the introduction of labels in the [output format](#output), badges are now optional in the `README.md` _if labels are used in the solution output_. If you do choose to add badges to your `README.md`, then: +With the introduction of [labels](#labels) in the [output format](#output), badges are now optional in the `README.md`, _provided that labels are indeed used in the solution output_. If you do choose to add badges to your `README.md`, then: * They need to comply with what is described in [the characteristics section](#characteristics). * If your solution includes multiple implementations that have different characteristics, then add all appropriate badges, once. * If your solution deviates from the basic [rules](#rules), add an additional badge, using the following template: @@ -194,7 +194,7 @@ This indicates if the implementation uses any form of parallelism. In this conte #### Label -As the [output](#output) of implementations specify how many threads are used, it is not needed to use a label to specify if an implementation is multi-threaded. +As the [output](#output) of implementations specifies how many threads are used, it is not needed to use a label to indicate if an implementation is multi-threaded. That is, if the thread count that is written to output is 1, then the implementation is considered to be single-threaded. If the output includes a higher thread count, then it is marked as a multi-threaded implementation. #### Badge @@ -281,7 +281,7 @@ where: * `iterations` is the amount of times your code ran in the allotted time. * `total_time` is the total time it took to run, which would be slightly more than 5 seconds, in an `en_US` formatted decimal value (so, use `.` (period) and not `,` (comma) as the decimal separator). * `num_threads` is the total amount of threads that were used to execute the indicated number of `iterations` (so 1 for a single-threaded solution). -* `labels` is an optional collection of name/value pairs that provide information on the [characteristics](#characteristics) of your implementation(s). They are discussed in more detail, below. +* `labels` is an optional collection of name/value pairs that provide information on the [characteristics](#characteristics) of your implementation(s). They are discussed in more detail, [below](#labels). Any other output should be directed to standard error, if possible. @@ -292,9 +292,10 @@ If you choose to include labels, then: * specificy each label as `=` * If multiple lables are included in your output, separate them with commas (`,`). * Don't use spaces between names, values, or name/value pairs -* If you don't output labels, then the semicolon (`;`) between `num_threads` and `labels` should also not be written. -Do note that default values are used for all labels that are not included. +If you don't output labels, then the semicolon (`;`) between `num_threads` and `labels` should also not be written. + +Do note that default values are used for all labels that are not included, as mentioned under [characteristics](#characteristics). ### Examples From 90a785d94056f285c848d9677eb7b3ee1372c388 Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Tue, 25 May 2021 22:00:53 +0200 Subject: [PATCH 05/14] Includes preference for multi-arch, small textual optimizations --- CONTRIBUTING.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 602146ef9..51c863ba6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,6 +57,13 @@ Also: * If the solution requires a significantly larger number of packages/files to build than it does to run, please define an `AS build` image for the build stage. * Do not include binary dependencies (executables, archives, etc) in your solution submission. If these are needed, create a base image on Docker Hub, preferably backed by a public GitHub repo under your account. +#### Support for hardware architectures +We encourage solutions and therefore Docker images to support both amd64/x86_64 and arm64/aarch64 hardware architecture. + +If your solution fundamentally supports only one architecture, you can use a "flag file" to indicate what architecture that is. Currently, examples of architecture-specific builds are the assembly builds for amd64 and arm64, respectively. + +A flag file is an empty file in the solution directory that tells the CI and benchmark implementations to build and run the solution only for/on the architecture indicated. The flag file for arm64 builds is `arch-arm64`, for amd64 builds it is `arch-amd64`. + ### Pull request Finally, submit a pull request **targeting the branch `drag-race`**, and place at least the name of the language in the title. Make sure to verify and check the contributing requirements that are summarized in the pull request template. @@ -68,11 +75,11 @@ Note that we cannot guarantee that we can help make your solution mergeable if i ## Rules -* Your solution uses the sieve of Erastosthenes. +* Your solution uses the [sieve of Erastosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes). * Your benchmarked code returns either a list of primes or the `is_prime` array, containing the result of the sieve. * Your solution runs for at least 5 seconds, and stops as quickly as possible after that. * Your solution calculates all the primes up to 1,000,000. -* You own copyright to all code and are willing to license that code under BSD-3 or compatible, or the code is available under BSD-3 or compatible. +* You own copyright to all code and are willing to license that code under BSD-new/BSD-3 or a more permissive license, or the code is available under BSD-new/BSD-3 or a more permissive license. ## Characteristics @@ -96,10 +103,10 @@ We currently consider the following algorithms to be "known" algorithms: | Name | Description | |-|-| | base | This is the algorithm that was used by @davepl in the YouTube video that spawned this repository. It is described in more detail, [below](#base-algorithm). | -| wheel | Algorithms rooted in the principle of [wheel factorization](https://en.wikipedia.org/wiki/Wheel_factorization). These tend to translate to having a (pre)calculated set of prime numbers within a certain base number range, that are then sequentially projected onto the sieve. | +| wheel | Algorithms rooted in the principle of [wheel factorization](https://en.wikipedia.org/wiki/Wheel_factorization). These tend to take a (pre)calculated set of prime numbers within a certain base number range, that are then sequentially projected onto the sieve. | | **other** | All algorithms that do not fall in the values already mentioned. This is used as the default if no algorithm is specified. | -**Note:** All implementations **must** use a form of [the Sieve of Erastosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) as the fundamental algorithm, as indicated in the basic [rules](#rules). +**Note:** All implementations **must** use a form of the [sieve of Erastosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) as the fundamental algorithm, as indicated in the base [rules](#rules). #### Base algorithm @@ -229,7 +236,7 @@ Common bit counts are: | 1 | Each prime number flag occupies one bit. Common implementations of this type use a bit array or bit masking on wider data types to get and set individual flags. | | 8 | Common implementations that occupy 8 bits per flag store the flags in a "byte" variable. | | 32 | Common implementations that occupy 32 bits per flag store the flags in a "regular" integer variable. | -| 64 | Common implementations that occupy 32 bits per flag store the flags in a "long" integer variable. | +| 64 | Common implementations that occupy 64 bits per flag store the flags in a "long" integer variable. | It's possible that the number of bits per flag is unknown. For example, this can be the case if an implementation uses a "boolean" basic type provided by the language, and the language does not define how booleans are logically stored in memory. From 295298f04cfa4792b1ec13bcb75e8db37e8a4fcd Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Tue, 25 May 2021 22:02:33 +0200 Subject: [PATCH 06/14] Deleted PrimeCSharp/solution_1/gobal.json --- PrimeCSharp/solution_1/global.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 PrimeCSharp/solution_1/global.json diff --git a/PrimeCSharp/solution_1/global.json b/PrimeCSharp/solution_1/global.json deleted file mode 100644 index 8c75c3238..000000000 --- a/PrimeCSharp/solution_1/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "5.0.201" - } -} From 823feac3e494785f65a314fa4f9456487c18e066 Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Sat, 29 May 2021 01:20:21 +0200 Subject: [PATCH 07/14] Added labels to my solutions --- PrimeAssembly/solution_1/README.md | 20 +++++++++++-------- PrimeAssembly/solution_1/primes_ff_bitbtr.asm | 2 +- .../solution_1/primes_ff_bitshift.asm | 2 +- PrimeAssembly/solution_1/primes_ff_byte.asm | 2 +- .../solution_1/primes_uff_bitbtr.asm | 2 +- .../solution_1/primes_uff_bitshift.asm | 2 +- PrimeAssembly/solution_1/primes_uff_byte.asm | 2 +- PrimeAssembly/solution_2/README.md | 13 +++++++----- .../solution_2/primes_arm64_bitmap.s | 2 +- .../solution_2/primes_arm64_bitshift.s | 2 +- PrimeAssembly/solution_2/primes_arm64_byte.s | 2 +- PrimeBASIC/solution_1/.gitignore | 1 + PrimeBASIC/solution_1/Dockerfile | 15 ++++++++------ PrimeBASIC/solution_1/README.md | 15 +++++++++----- PrimeBASIC/solution_1/prime_8of30.bas | 2 +- PrimeBASIC/solution_1/prime_bit32.bas | 2 +- PrimeBASIC/solution_1/prime_bit64.bas | 2 +- PrimeBASIC/solution_1/prime_boolean.bas | 2 +- .../solution_1/{runprimes.sh => run.sh} | 2 +- PrimeBASIC/solution_2/PrimeVB.vb | 2 +- PrimeBASIC/solution_2/README.md | 7 +++++-- PrimeFSharp/solution_1/Program.fs | 2 +- PrimeFSharp/solution_1/README.md | 7 +++++-- PrimeMIXAL/solution_1/README.md | 13 +++++++----- PrimeMIXAL/solution_1/prime.mixal | 9 ++++++++- PrimePascal/solution_1/README.md | 7 +++++-- PrimePascal/solution_1/prime.pas | 2 +- PrimeRuby/solution_1/README.md | 7 +++++-- PrimeRuby/solution_1/prime.rb | 2 +- 29 files changed, 94 insertions(+), 56 deletions(-) create mode 100644 PrimeBASIC/solution_1/.gitignore rename PrimeBASIC/solution_1/{runprimes.sh => run.sh} (77%) diff --git a/PrimeAssembly/solution_1/README.md b/PrimeAssembly/solution_1/README.md index 3ee666629..69edb5422 100644 --- a/PrimeAssembly/solution_1/README.md +++ b/PrimeAssembly/solution_1/README.md @@ -1,7 +1,11 @@ # x86-64 assembly solution by rbergen -![Category](https://img.shields.io/badge/Category-faithful-green) -![Category](https://img.shields.io/badge/Category-unfaithful-yellowgreen) +![Algorithm](https://img.shields.io/badge/Algorithm-base-green) +![Faithfulness](https://img.shields.io/badge/Faithful-yes-green) +![Faithfulness](https://img.shields.io/badge/Faithful-no-yellowgreen) +![Parallelism](https://img.shields.io/badge/Parallel-no-green) +![Bit count](https://img.shields.io/badge/Bits-1-green) +![Bit count](https://img.shields.io/badge/Bits-8-yellowgreen) This solution contains six implementations in x86-64 assembly, of which: * x64ff_bitbtr is faithful, uses bits to store prime number flags and clears them using the btr instruction @@ -27,10 +31,10 @@ A Dockerfile has been provided. ## Output ``` -rbergen_x64uff_byte;7334;5.000;1 -rbergen_x64ff_byte;8302;5.000;1 -rbergen_x64uff_bitbtr;4179;5.000;1 -rbergen_x64ff_bitbtr;4177;5.000;1 -rbergen_x64uff_bitshift;6269;5.000;1 -rbergen_x64ff_bitshift;4600;5.000;1 +rbergen_x64uff_byte;7334;5.000;1;algorithm=base,faithful=no,bits=8 +rbergen_x64ff_byte;8302;5.000;1;algorithm=base,faithful=yes,bits=8 +rbergen_x64uff_bitbtr;4179;5.000;1;algorithm=base,faithful=no,bits=1 +rbergen_x64ff_bitbtr;4177;5.000;1;algorithm=base,faithful=yes,bits=1 +rbergen_x64uff_bitshift;6269;5.000;1;algorithm=base,faithful=no,bits=1 +rbergen_x64ff_bitshift;4600;5.000;1;algorithm=base,faithful=yes,bits=1 ``` \ No newline at end of file diff --git a/PrimeAssembly/solution_1/primes_ff_bitbtr.asm b/PrimeAssembly/solution_1/primes_ff_bitbtr.asm index 6aeb79488..69d0083d6 100644 --- a/PrimeAssembly/solution_1/primes_ff_bitbtr.asm +++ b/PrimeAssembly/solution_1/primes_ff_bitbtr.asm @@ -50,7 +50,7 @@ refResults: dd 0 ; format string for output -outputFmt: db 'rbergen_x64ff_bitbtr', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0 +outputFmt: db 'rbergen_x64ff_bitbtr', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=yes,bits=1', 10, 0 ; incorrect result warning message incorrect: db 'WARNING: result is incorrect!', 10 ; length of previous diff --git a/PrimeAssembly/solution_1/primes_ff_bitshift.asm b/PrimeAssembly/solution_1/primes_ff_bitshift.asm index c6d0ef0a1..6f0fd0996 100644 --- a/PrimeAssembly/solution_1/primes_ff_bitshift.asm +++ b/PrimeAssembly/solution_1/primes_ff_bitshift.asm @@ -50,7 +50,7 @@ refResults: dd 0 ; format string for output -outputFmt: db 'rbergen_x64ff_bitshift', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0 +outputFmt: db 'rbergen_x64ff_bitshift', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=yes,bits=1', 10, 0 ; incorrect result warning message incorrect: db 'WARNING: result is incorrect!', 10 ; length of previous diff --git a/PrimeAssembly/solution_1/primes_ff_byte.asm b/PrimeAssembly/solution_1/primes_ff_byte.asm index 0d3b82fd6..19b810be6 100644 --- a/PrimeAssembly/solution_1/primes_ff_byte.asm +++ b/PrimeAssembly/solution_1/primes_ff_byte.asm @@ -50,7 +50,7 @@ refResults: dd 0 ; format string for output -outputFmt: db 'rbergen_x64ff_byte', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0 +outputFmt: db 'rbergen_x64ff_byte', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=yes,bits=8', 10, 0 ; incorrect result warning message incorrect: db 'WARNING: result is incorrect!', 10 ; length of previous diff --git a/PrimeAssembly/solution_1/primes_uff_bitbtr.asm b/PrimeAssembly/solution_1/primes_uff_bitbtr.asm index becbca24b..d40b24e72 100644 --- a/PrimeAssembly/solution_1/primes_uff_bitbtr.asm +++ b/PrimeAssembly/solution_1/primes_uff_bitbtr.asm @@ -45,7 +45,7 @@ refResults: dd 0 ; format string for output -outputFmt: db 'rbergen_x64uff_bitbtr', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0 +outputFmt: db 'rbergen_x64uff_bitbtr', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=no,bits=1', 10, 0 ; incorrect result warning message incorrect: db 'WARNING: result is incorrect!', 10 ; length of previous diff --git a/PrimeAssembly/solution_1/primes_uff_bitshift.asm b/PrimeAssembly/solution_1/primes_uff_bitshift.asm index fdb8deef5..605172066 100644 --- a/PrimeAssembly/solution_1/primes_uff_bitshift.asm +++ b/PrimeAssembly/solution_1/primes_uff_bitshift.asm @@ -45,7 +45,7 @@ refResults: dd 0 ; format string for output -outputFmt: db 'rbergen_x64uff_bitshift', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0 +outputFmt: db 'rbergen_x64uff_bitshift', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=no,bits=1', 10, 0 ; incorrect result warning message incorrect: db 'WARNING: result is incorrect!', 10 ; length of previous diff --git a/PrimeAssembly/solution_1/primes_uff_byte.asm b/PrimeAssembly/solution_1/primes_uff_byte.asm index e83b2790d..399f68080 100644 --- a/PrimeAssembly/solution_1/primes_uff_byte.asm +++ b/PrimeAssembly/solution_1/primes_uff_byte.asm @@ -45,7 +45,7 @@ refResults: dd 0 ; format string for output -outputFmt: db 'rbergen_x64uff_byte', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', 10, 0 +outputFmt: db 'rbergen_x64uff_byte', SEMICOLON, '%d', SEMICOLON, '%d.%03d', SEMICOLON, '1', SEMICOLON, 'algorithm=base,faithful=no,bits=8', 10, 0 ; incorrect result warning message incorrect: db 'WARNING: result is incorrect!', 10 ; length of previous diff --git a/PrimeAssembly/solution_2/README.md b/PrimeAssembly/solution_2/README.md index 38174173f..f900055cf 100644 --- a/PrimeAssembly/solution_2/README.md +++ b/PrimeAssembly/solution_2/README.md @@ -1,7 +1,10 @@ # arm64 assembly solution by rbergen -![Category](https://img.shields.io/badge/Category-faithful-green) - +![Algorithm](https://img.shields.io/badge/Algorithm-base-green) +![Faithfulness](https://img.shields.io/badge/Faithful-yes-green) +![Parallelism](https://img.shields.io/badge/Parallel-no-green) +![Bit count](https://img.shields.io/badge/Bits-1-green) +![Bit count](https://img.shields.io/badge/Bits-8-yellowgreen) This solution contains three implementations in arm64 assembly. Two use bits to store prime number flags (one with precalculated bit masks), the other uses bytes. The basic algorithm used is that of the original C#/C++ implementations. @@ -19,7 +22,7 @@ A Dockerfile has been provided. ## Output ``` -rbergen_arm64_byte;908;5.002;1 -rbergen_arm64_bitmap;793;5.005;1 -rbergen_arm64_bitshift;890;5.003;1 +rbergen_arm64_byte;908;5.002;1;algorithm=base,faithful=yes,bits=8 +rbergen_arm64_bitmap;793;5.005;1;algorithm=base,faithful=yes,bits=1 +rbergen_arm64_bitshift;890;5.003;1;algorithm=base,faithful=yes,bits=1 ``` \ No newline at end of file diff --git a/PrimeAssembly/solution_2/primes_arm64_bitmap.s b/PrimeAssembly/solution_2/primes_arm64_bitmap.s index f832df504..c77298da3 100644 --- a/PrimeAssembly/solution_2/primes_arm64_bitmap.s +++ b/PrimeAssembly/solution_2/primes_arm64_bitmap.s @@ -209,7 +209,7 @@ printResults: .balign 4 outputFmt: // format string for output -.asciz "rbergen_arm64_bitmap;%d;%d.%03d;1\n" +.asciz "rbergen_arm64_bitmap;%d;%d.%03d;1;algorithm=base,faithful=yes,bits=1\n" .balign 4 diff --git a/PrimeAssembly/solution_2/primes_arm64_bitshift.s b/PrimeAssembly/solution_2/primes_arm64_bitshift.s index 4ee67c6a3..3ccde10a2 100644 --- a/PrimeAssembly/solution_2/primes_arm64_bitshift.s +++ b/PrimeAssembly/solution_2/primes_arm64_bitshift.s @@ -209,7 +209,7 @@ printResults: .balign 4 outputFmt: // format string for output -.asciz "rbergen_arm64_bitshift;%d;%d.%03d;1\n" +.asciz "rbergen_arm64_bitshift;%d;%d.%03d;1;algorithm=base,faithful=yes,bits=1\n" .balign 4 diff --git a/PrimeAssembly/solution_2/primes_arm64_byte.s b/PrimeAssembly/solution_2/primes_arm64_byte.s index 5b7f1f66a..02576e65b 100644 --- a/PrimeAssembly/solution_2/primes_arm64_byte.s +++ b/PrimeAssembly/solution_2/primes_arm64_byte.s @@ -209,7 +209,7 @@ printResults: .balign 4 outputFmt: // format string for output -.asciz "rbergen_arm64_byte;%d;%d.%03d;1\n" +.asciz "rbergen_arm64_byte;%d;%d.%03d;1;algorithm=base,faithful=yes,bits=8\n" .balign 4 diff --git a/PrimeBASIC/solution_1/.gitignore b/PrimeBASIC/solution_1/.gitignore new file mode 100644 index 000000000..a2a20a649 --- /dev/null +++ b/PrimeBASIC/solution_1/.gitignore @@ -0,0 +1 @@ +*.run \ No newline at end of file diff --git a/PrimeBASIC/solution_1/Dockerfile b/PrimeBASIC/solution_1/Dockerfile index a89c26f3e..67fab37c7 100644 --- a/PrimeBASIC/solution_1/Dockerfile +++ b/PrimeBASIC/solution_1/Dockerfile @@ -1,12 +1,15 @@ FROM primeimages/freebasic:1.07.3 AS build + WORKDIR /opt/app -COPY runprimes.sh . -RUN chmod a+x runprimes.sh -COPY *.bas /opt/app/ -RUN find . -name 'prime_*.bas' -exec fbc {} \; +COPY *.bas ./ +COPY run.sh . +RUN chmod a+x run.sh +RUN find . -name 'prime_*.bas' -exec fbc {} -x {}.run \; FROM ubuntu:18.04 -COPY --from=build /opt/app/* /opt/app/ +COPY --from=build /opt/app/*.run /opt/app/ +COPY --from=build /opt/app/run.sh /opt/app/ +WORKDIR /opt/app -ENTRYPOINT [ "/opt/app/runprimes.sh" ] \ No newline at end of file +ENTRYPOINT [ "./run.sh" ] \ No newline at end of file diff --git a/PrimeBASIC/solution_1/README.md b/PrimeBASIC/solution_1/README.md index 3deb9746f..b7fa18388 100644 --- a/PrimeBASIC/solution_1/README.md +++ b/PrimeBASIC/solution_1/README.md @@ -1,6 +1,11 @@ # FreeBASIC solutions by rbergen -![Category](https://img.shields.io/badge/Category-faithful-green) +![Algorithm](https://img.shields.io/badge/Algorithm-base-green) +![Algorithm](https://img.shields.io/badge/Algorithm-wheel-yellowgreen) +![Faithfulness](https://img.shields.io/badge/Faithful-yes-green) +![Parallelism](https://img.shields.io/badge/Parallel-no-green) +![Bit count](https://img.shields.io/badge/Bits-1-green) +![Bit count](https://img.shields.io/badge/Bits-unknown-yellowgreen) This is a collection of implementations in FreeBASIC, of which: 1. one is effectively a FreeBASIC copy of the "8 of 30" implementation that [mckoss](https://github.com/mckoss) has written in C @@ -22,8 +27,8 @@ A Dockerfile has been provided. ## Output ``` -rbergen_8of30;4197;5.001;1 -rbergen_bit32;720;5.000;1 -rbergen_bit64;661;5.000;1 -rbergen_boolean;1720;5.001;1 +rbergen_8of30;4197;5.001;1;algorithm=wheel,faithful=yes,bits=1 +rbergen_bit32;720;5.000;1;algorithm=base,faithful=yes,bits=1 +rbergen_bit64;661;5.000;1;algorithm=base,faithful=yes,bits=1 +rbergen_boolean;1720;5.001;1;algorithm=base,faithful=yes ``` \ No newline at end of file diff --git a/PrimeBASIC/solution_1/prime_8of30.bas b/PrimeBASIC/solution_1/prime_8of30.bas index 1bef878f0..bfbfc2035 100644 --- a/PrimeBASIC/solution_1/prime_8of30.bas +++ b/PrimeBASIC/solution_1/prime_8of30.bas @@ -181,4 +181,4 @@ If GetReferenceResult(SieveSize) <> Sieve->CountPrimes() Then Print "WARNING: re Delete Sieve -Print Using "rbergen__8of30;&;#.###;1"; PassCount; Duration \ No newline at end of file +Print Using "rbergen__8of30;&;#.###;1;algorithm=wheel,faithful=yes,bits=1"; PassCount; Duration \ No newline at end of file diff --git a/PrimeBASIC/solution_1/prime_bit32.bas b/PrimeBASIC/solution_1/prime_bit32.bas index 4406173c7..334c360fa 100644 --- a/PrimeBASIC/solution_1/prime_bit32.bas +++ b/PrimeBASIC/solution_1/prime_bit32.bas @@ -167,4 +167,4 @@ If GetReferenceResult(SieveSize) <> Sieve->CountPrimes() Then Print "WARNING: re Delete Sieve -Print Using "rbergen__bit32;&;#.###;1"; PassCount; Duration \ No newline at end of file +Print Using "rbergen__bit32;&;#.###;1;algorithm=base,faithful=yes,bits=1"; PassCount; Duration \ No newline at end of file diff --git a/PrimeBASIC/solution_1/prime_bit64.bas b/PrimeBASIC/solution_1/prime_bit64.bas index 26cc582dd..f9bc299a6 100644 --- a/PrimeBASIC/solution_1/prime_bit64.bas +++ b/PrimeBASIC/solution_1/prime_bit64.bas @@ -167,4 +167,4 @@ If GetReferenceResult(SieveSize) <> Sieve->CountPrimes() Then Print "WARNING: re Delete Sieve -Print Using "rbergen__bit64;&;#.###;1"; PassCount; Duration \ No newline at end of file +Print Using "rbergen__bit64;&;#.###;1;algorithm=base,faithful=yes,bits=1"; PassCount; Duration \ No newline at end of file diff --git a/PrimeBASIC/solution_1/prime_boolean.bas b/PrimeBASIC/solution_1/prime_boolean.bas index 5cbdbc2f3..d3e028808 100644 --- a/PrimeBASIC/solution_1/prime_boolean.bas +++ b/PrimeBASIC/solution_1/prime_boolean.bas @@ -132,4 +132,4 @@ If GetReferenceResult(SieveSize) <> Sieve->CountPrimes() Then Print "WARNING: re Delete Sieve -Print Using "rbergen__boolean;&;#.###;1"; PassCount; Duration \ No newline at end of file +Print Using "rbergen__boolean;&;#.###;1;algorithm=base,faithful=yes"; PassCount; Duration \ No newline at end of file diff --git a/PrimeBASIC/solution_1/runprimes.sh b/PrimeBASIC/solution_1/run.sh similarity index 77% rename from PrimeBASIC/solution_1/runprimes.sh rename to PrimeBASIC/solution_1/run.sh index 12081f0a1..c46047e82 100644 --- a/PrimeBASIC/solution_1/runprimes.sh +++ b/PrimeBASIC/solution_1/run.sh @@ -2,7 +2,7 @@ cd $(dirname "${BASH_SOURCE[0]}") -for file in prime_*[^.bas]; do +for file in prime_*.run; do if [ -x ${file} ]; then ./${file} fi diff --git a/PrimeBASIC/solution_2/PrimeVB.vb b/PrimeBASIC/solution_2/PrimeVB.vb index 1e4f6d1bd..d93fd6300 100644 --- a/PrimeBASIC/solution_2/PrimeVB.vb +++ b/PrimeBASIC/solution_2/PrimeVB.vb @@ -79,6 +79,6 @@ Module PrimeVB Console.WriteLine("WARNING: result is incorrect!") End If - Console.WriteLine("rbergen_vb;{0};{1};1", passCount, duration) + Console.WriteLine("rbergen_vb;{0};{1};1;algorithm=base,faithful=yes,bits=1", passCount, duration) End Sub End Module diff --git a/PrimeBASIC/solution_2/README.md b/PrimeBASIC/solution_2/README.md index c967e86f7..1af45db69 100644 --- a/PrimeBASIC/solution_2/README.md +++ b/PrimeBASIC/solution_2/README.md @@ -1,6 +1,9 @@ # Visual Basic solution by rbergen -![Category](https://img.shields.io/badge/Category-faithful-green) +![Algorithm](https://img.shields.io/badge/Algorithm-base-green) +![Faithfulness](https://img.shields.io/badge/Faithful-yes-green) +![Parallelism](https://img.shields.io/badge/Parallel-no-green) +![Bit count](https://img.shields.io/badge/Bits-1-green) This is an implementation in Visual Basic. @@ -17,5 +20,5 @@ A Dockerfile has been provided. ## Output ``` -rbergen_vb;2457;5.0012308;1 +rbergen_vb;2457;5.0012308;1;algorithm=base,faithful=yes,bits=1 ``` \ No newline at end of file diff --git a/PrimeFSharp/solution_1/Program.fs b/PrimeFSharp/solution_1/Program.fs index 53f055d33..cce62e6ee 100644 --- a/PrimeFSharp/solution_1/Program.fs +++ b/PrimeFSharp/solution_1/Program.fs @@ -79,7 +79,7 @@ let main _argv = if sieve.CountPrimes <> referenceResults.[sieveSize] then printfn "WARNING: result is incorrect!" - printfn $"rbergen;{ passCount };{ duration };1" + printfn $"rbergen;{ passCount };{ duration };1;algorithm=base,faithful=yes,bits=1" 0 diff --git a/PrimeFSharp/solution_1/README.md b/PrimeFSharp/solution_1/README.md index ea994dae3..460cd7586 100644 --- a/PrimeFSharp/solution_1/README.md +++ b/PrimeFSharp/solution_1/README.md @@ -1,6 +1,9 @@ # F# solution by rbergen -![Category](https://img.shields.io/badge/Category-faithful-green) +![Algorithm](https://img.shields.io/badge/Algorithm-base-green) +![Faithfulness](https://img.shields.io/badge/Faithful-yes-green) +![Parallelism](https://img.shields.io/badge/Parallel-no-green) +![Bit count](https://img.shields.io/badge/Bits-1-green) This is an implementation in F#. @@ -17,5 +20,5 @@ A Dockerfile has been provided. ## Output ``` -rbergen;3468;5.0011417;1 +rbergen;3468;5.0011417;1;algorithm=base,faithful=yes,bits=1 ``` \ No newline at end of file diff --git a/PrimeMIXAL/solution_1/README.md b/PrimeMIXAL/solution_1/README.md index 538985137..d0cad8a17 100644 --- a/PrimeMIXAL/solution_1/README.md +++ b/PrimeMIXAL/solution_1/README.md @@ -1,7 +1,10 @@ # MIXAL solution by rbergen -![Category](https://img.shields.io/badge/Category-unfaithful-yellowgreen) -![Category](https://img.shields.io/badge/Category-approximation-blue) +![Algorithm](https://img.shields.io/badge/Algorithm-base-green) +![Faithfulness](https://img.shields.io/badge/Faithful-no-yellowgreen) +![Parallelism](https://img.shields.io/badge/Parallel-no-green) +![Bit count](https://img.shields.io/badge/Bits-1-green) +![Deviation](https://img.shields.io/badge/Deviation-sievesize-blue) *Category: Unfaithful / Closest Approximation* @@ -16,7 +19,7 @@ Due to this, the core implementation deviates from the basic rules in two ways: * By default, the sieve size is 200,000 instead of 1,000,000. The reason is that MIX has a total memory capacity of 3,999 words, each 30 bits wide. This does not allow for a bit array of 500,000 entries to be stored. In the practical sense, a sieve size of 200,000 is the maximum. * The implementation does itself not run for a period of 5 seconds. Instead, depending on configuration it will either execute a configured number of sieve runs, or keep repeating sieve runs indefinitely. The reason is that MIX has no internal clock that measures actual time. Instruction execution times are measured in "ticks", the duration of which is undefined, by design. In practice, this means that if a timed execution is desired, the starting, timing and stopping of it must be controlled external to the program. -These deviations are part of the implementation out of necessity, but I have made a genuine effort to stay as close to the original implementation(s) and the basic rules as possible. It is therefore that I have labeled the category as "approximation". +These deviations are part of the implementation out of necessity, but I have made a genuine effort to stay as close to the original implementation(s) and the basic rules as possible. To mitigate the second deviation, the implementation comes with a wrapper shell script that: * Times the run of the implementation externally, using the GNU time command @@ -108,7 +111,7 @@ RUN: 00027, SIEVE: 0000200000, PRIMES: 17984, RESULT: CORRECT RUN: 00028, SIEVE: 0000200000, PRIMES: 17984, RESULT: CORRECT RUN: 00029, SIEVE: 0000200000, PRIMES: 17984, RESULT: CORRECT RUN: 00030, SIEVE: 0000200000, PRIMES: 17984, RESULT: CORRECT -RBERGEN;30;