Loading .gitlab-ci.yml +6 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,9 @@ build:xk7: <<: *build <<: *xk7 script: - module load python && ./breakable.py -t build_hello_world - module swap PrgEnv-pgi PrgEnv-gnu - module load python - ./breakable.py -t build_hello_world run:xk7: <<: *run Loading @@ -54,7 +56,9 @@ build:xc30: <<: *build <<: *xc30 script: - module load python && ./breakable.py -t build_hello_world - module swap PrgEnv-intel PrgEnv-gnu - module load python - ./breakable.py -t build_hello_world run:xc30: <<: *run Loading Breakfile.py +2 −3 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ import platform class BreakTasks(object): @provides("hello_world.exe") def build_hello_world(self): needs("main.cpp") self.CC("main.cpp -o hello_world.exe") Loading @@ -27,11 +26,11 @@ class Platform(object): class Mac(Platform): name = "Mac OS X" CC = which("c++") CC = which("c++", defaults=["-std=c++11","-stdlib=libc++"]) class Linux(Platform): name = "Linux" CC = which("CC") CC = which("CC", defaults=["-std=c++11"]) def detect_platform(): if platform.system() == 'Linux': Loading main.cpp +34 −0 Original line number Diff line number Diff line #include <iostream> #include <array> #include <string> #include "platform.h" typedef uint64_t natural; bool is_coprime(natural known_prime, natural potential_coprime) { return (potential_coprime % known_prime != 0); } bool is_not_coprime(natural known_prime, natural potential_coprime) { return ! is_coprime(known_prime, potential_coprime); } bool is_relatively_prime_to_list(std::array<natural,5> known_primes, natural potential_coprime) { for (auto it = known_primes.begin(); it != known_primes.end(); ++it) { if (is_not_coprime(*it, potential_coprime)) return false; } return true; } std::string bool_to_yes_or_no(bool boolean_value) { return (boolean_value == true ? "Yes" : "No"); } void print_whether_N_is_prime(std::array<natural,5> known_primes, natural N) { std::cout << "Is " << N << " a prime number? "; bool result = is_relatively_prime_to_list(known_primes, N); std::cout << bool_to_yes_or_no(result); std::cout << std::endl; } int main(int argc, char** argv) { std::cout << "Hello from " << PLATFORM << "\n"; std::array<natural,5> known_primes = { 2, 3, 5, 7, 11 }; print_whether_N_is_prime(known_primes, 12); print_whether_N_is_prime(known_primes, 13); return 0; } Loading
.gitlab-ci.yml +6 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,9 @@ build:xk7: <<: *build <<: *xk7 script: - module load python && ./breakable.py -t build_hello_world - module swap PrgEnv-pgi PrgEnv-gnu - module load python - ./breakable.py -t build_hello_world run:xk7: <<: *run Loading @@ -54,7 +56,9 @@ build:xc30: <<: *build <<: *xc30 script: - module load python && ./breakable.py -t build_hello_world - module swap PrgEnv-intel PrgEnv-gnu - module load python - ./breakable.py -t build_hello_world run:xc30: <<: *run Loading
Breakfile.py +2 −3 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ import platform class BreakTasks(object): @provides("hello_world.exe") def build_hello_world(self): needs("main.cpp") self.CC("main.cpp -o hello_world.exe") Loading @@ -27,11 +26,11 @@ class Platform(object): class Mac(Platform): name = "Mac OS X" CC = which("c++") CC = which("c++", defaults=["-std=c++11","-stdlib=libc++"]) class Linux(Platform): name = "Linux" CC = which("CC") CC = which("CC", defaults=["-std=c++11"]) def detect_platform(): if platform.system() == 'Linux': Loading
main.cpp +34 −0 Original line number Diff line number Diff line #include <iostream> #include <array> #include <string> #include "platform.h" typedef uint64_t natural; bool is_coprime(natural known_prime, natural potential_coprime) { return (potential_coprime % known_prime != 0); } bool is_not_coprime(natural known_prime, natural potential_coprime) { return ! is_coprime(known_prime, potential_coprime); } bool is_relatively_prime_to_list(std::array<natural,5> known_primes, natural potential_coprime) { for (auto it = known_primes.begin(); it != known_primes.end(); ++it) { if (is_not_coprime(*it, potential_coprime)) return false; } return true; } std::string bool_to_yes_or_no(bool boolean_value) { return (boolean_value == true ? "Yes" : "No"); } void print_whether_N_is_prime(std::array<natural,5> known_primes, natural N) { std::cout << "Is " << N << " a prime number? "; bool result = is_relatively_prime_to_list(known_primes, N); std::cout << bool_to_yes_or_no(result); std::cout << std::endl; } int main(int argc, char** argv) { std::cout << "Hello from " << PLATFORM << "\n"; std::array<natural,5> known_primes = { 2, 3, 5, 7, 11 }; print_whether_N_is_prime(known_primes, 12); print_whether_N_is_prime(known_primes, 13); return 0; }