Skip to content

This repository was made to test the speed of C++'s constexpr values (at runtime) in comparison to the traditional Sieve of Eratosthenes optimization. NOTE: The SIMD solution doesn't work.

License

Notifications You must be signed in to change notification settings

1Git2Clone/prime-nums-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prime-nums-test

IMPORTANT NOTE

The SIMD solution (-se) doesn't actually work.

Setting up

Minimal compiling options (for g++ on the ROOT directory of the REPOSITORY):

  • -ftemplate-depth=PRIME_UPPER_LIMIT+1 -> this needs to be the minimum value.
g++ src/main.cpp -o bin/test -march=native -mavx -ftemplate-depth=1001 -Ofast

The -Ofast flag for g++ is optional.

g++ src/main.cpp -o bin/test -march=native -mavx -ftemplate-depth=1001

No -Ofast variant.

Running variations:

  • -eval (-e) flag runs the barebones unoptimized solution.
  • -sieve-of-eratosthenes (-soe) flag runs a more optimized version using modulo math. (wikipedia.org)
  • -simd-eval (-se) flag runs the same -soe flag but with AVX2 (NOT WORKING FOR NOW!).
  • -constexpr-eval (-ce) flag is the reason why your compile times are slow. It runs on compile time instead of runtime. On runtime it just gets printed.

Additional details

This project was just made as a test related to this YouTube video

The constexpr data type is really interesting and I never used it before. Basically its used for evaluations on compile time, saving runtime resources for specific predefined data. This is useful but I do wonder which exact use cases are the best for it... Aggressive GCC optimize flags tend to do the job just fine and usually you'd be looking at data caching evaluations for the flexibility of your app.

About

This repository was made to test the speed of C++'s constexpr values (at runtime) in comparison to the traditional Sieve of Eratosthenes optimization. NOTE: The SIMD solution doesn't work.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages