Loading ci_cd/.gitlab-ci.yml +2 −0 Original line number Diff line number Diff line Loading @@ -2,7 +2,9 @@ stages: - prebuild - compile - test - more - efficiency - benchmark include: - local: 'ci_cd/problem3.yml' # FullInteger Loading ci_cd/problem3.yml +69 −2 Original line number Diff line number Diff line Loading @@ -47,11 +47,78 @@ exec_problem_3: - if: '$CI_COMMIT_REF_NAME == "problem3"' tags: [c++-17] benchmark: stage: efficiency more_problem_3: stage: more needs: - job: exec_problem_3 artifacts: true script: - cd hw3/tests - make more3 - ./more3 > more3.txt - score="$(tail -n 1 more3.txt | tr -d '[:space:]')" - echo "$(cat more3.txt)" - echo "More-test score is $score" - STUDENT="$(echo "$CI_PROJECT_PATH" | sed -E 's#.*/HomeworkThree##')" - curl "https://agile.bu.edu/ec330_scripts/saveScores.pl?key=${MAGIC_KEY}&file=hw3_more3&name=${STUDENT}&score=${score}" artifacts: paths: - hw3/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3"' tags: [c++-17] efficiency_problem_3: stage: efficiency needs: - job: more_problem_3 artifacts: true script: - cd hw3/tests - make efficiency3 - set -o pipefail - | set +e timeout 180s stdbuf -oL ./efficiency3 > efficiency3.out STATUS=$? set -e context="$(tail -n 20 efficiency3.out | tail -c 500)" if [ "$STATUS" -eq 124 ]; then echo "Timeout!" exit 1 fi if [ "$STATUS" -eq 134 ] || [ "$STATUS" -eq 137 ]; then echo "Out of memory (status $STATUS) — aborted (134) or killed (137)" echo "Context: $context" exit 1 fi if [ "$STATUS" -ge 128 ] && [ "$STATUS" -le 192 ]; then sig=$((STATUS - 128)) echo "Crashed / terminated by signal $sig (exit $STATUS)" echo "Context: $context" exit 1 fi score="$(tail -n 1 efficiency3.out | tr -d '[:space:]')" - echo "$(cat efficiency3.out)" - echo "Efficiency score is $score" - STUDENT="$(echo "$CI_PROJECT_PATH" | sed -E 's#.*/HomeworkThree##')" - curl "https://agile.bu.edu/ec330_scripts/saveScores.pl?key=${MAGIC_KEY}&file=hw3_eff3&name=${STUDENT}&score=${score}" artifacts: paths: - hw3/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3"' timeout: 5m tags: [c++-17] benchmark: stage: benchmark needs: - job: efficiency_problem_3 artifacts: true script: - git clone https://trachten-gitlab:${HW_INTERNAL}@agile.bu.edu/gitlab/ec330/ec330_staff/homeworks_internal/hw3_ec.git hw3_ec - cp impl/FullInteger.cpp hw3_ec/impl Loading tests/Makefile +16 −4 Original line number Diff line number Diff line Loading @@ -6,23 +6,35 @@ CXXFLAGS = -std=c++17 # Source files PROBLEM3_SRCS = testFullInteger.cpp impl/FullInteger.cpp impl/IntegerPP.cpp impl/IntegerP.cpp impl/BigNum.cpp SRCS = $(PROBLEM3_SRCS) MORE3_SRCS = testMoreFullInteger.cpp impl/FullInteger.cpp impl/IntegerPP.cpp impl/IntegerP.cpp impl/BigNum.cpp EFFICIENCY3_SRCS = testEfficiencyFullInteger.cpp impl/RefFullInteger.cpp impl/FullInteger.cpp impl/IntegerPP.cpp impl/IntegerP.cpp impl/BigNum.cpp SRCS = $(PROBLEM3_SRCS) $(MORE3_SRCS) $(EFFICIENCY3_SRCS) # Object files PROBLEM3_OBJS = testFullInteger.o impl/FullInteger.o impl/IntegerPP.o impl/IntegerP.o impl/BigNum.o OBJS = $(PROBLEM3_OBJS) MORE3_OBJS = testMoreFullInteger.o impl/FullInteger.o impl/IntegerPP.o impl/IntegerP.o impl/BigNum.o EFFICIENCY3_OBJS = testEfficiencyFullInteger.o impl/RefFullInteger.o impl/FullInteger.o impl/IntegerPP.o impl/IntegerP.o impl/BigNum.o OBJS = $(PROBLEM3_OBJS) $(MORE3_OBJS) $(EFFICIENCY3_OBJS) # Executable name PROBLEM3_EXEC = problem3 EXECS = $(PROBLEM3_EXEC) MORE3_EXEC = more3 EFFICIENCY3_EXEC = efficiency3 EXECS = $(PROBLEM3_EXEC) $(MORE3_EXEC) $(EFFICIENCY3_EXEC) # Default target to build the executable all: $(PROBLEM3_EXEC) all: $(PROBLEM3_EXEC) $(MORE3_EXEC) $(EFFICIENCY3_EXEC) # Rule to build the executable from object files $(PROBLEM3_EXEC): $(PROBLEM3_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM3_EXEC) $(PROBLEM3_OBJS) $(MORE3_EXEC): $(MORE3_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(MORE3_EXEC) $(MORE3_OBJS) $(EFFICIENCY3_EXEC): $(EFFICIENCY3_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(EFFICIENCY3_EXEC) $(EFFICIENCY3_OBJS) # Rules to build object files from source files %.o: %.cpp Makefile $(CXX) $(CXXFLAGS) -c $< -o $@ Loading tests/impl/RefFullInteger.cpp 0 → 100644 +36 −0 Original line number Diff line number Diff line // // Created by Ari on 2/22/26. // #include <iostream> #include <algorithm> #include <cmath> #include "../include/BigNum.h" #include "../include/RefFullInteger.h" using namespace std; // forward declaration unsigned int ithPrime(const size_t ii); bool RefFullInteger::operator<=(const FullInteger &other) const { double myLog = 0.0; auto myPrimes = primePowers(); for (int ii=0; ii<myPrimes[ii]; ++ii) { if (myPrimes[ii]!=0) myLog += myPrimes[ii] * log(ithPrime(ii)); } double otherLog = 0.0; auto otherPrimes = other.primePowers(); for (int ii=0; ii<otherPrimes.size(); ++ii) { if (otherPrimes[ii]!=0) otherLog += otherPrimes[ii] * log(ithPrime(ii)); } return myLog <= otherLog; } void RefFullInteger::limitedSort(vector<FullInteger>& nums, int largestPrimeFactor) { std::sort(nums.begin(), nums.end()); } No newline at end of file tests/include/RefFullInteger.h 0 → 100644 +20 −0 Original line number Diff line number Diff line // // Created by Ari on 2/28/26. // #ifndef HW3_EC_REFFULLINTEGER_H #define HW3_EC_REFFULLINTEGER_H #include "FullInteger.h" class RefFullInteger:public FullInteger { public: RefFullInteger() = default; RefFullInteger(unsigned long n) : FullInteger(n) {} RefFullInteger(std::initializer_list<int> pBasis) : FullInteger(pBasis) {} RefFullInteger(vector<int> pBasis) { _primePowers = pBasis; } RefFullInteger(const IntegerP& other) : FullInteger(other) {} explicit RefFullInteger(const BigNum& num) : FullInteger(num) {} bool operator<=(const FullInteger &other) const; static void limitedSort(vector<FullInteger> &nums, int largestPrimeFactor); }; #endif //HW3_EC_REFFULLINTEGER_H No newline at end of file Loading
ci_cd/.gitlab-ci.yml +2 −0 Original line number Diff line number Diff line Loading @@ -2,7 +2,9 @@ stages: - prebuild - compile - test - more - efficiency - benchmark include: - local: 'ci_cd/problem3.yml' # FullInteger Loading
ci_cd/problem3.yml +69 −2 Original line number Diff line number Diff line Loading @@ -47,11 +47,78 @@ exec_problem_3: - if: '$CI_COMMIT_REF_NAME == "problem3"' tags: [c++-17] benchmark: stage: efficiency more_problem_3: stage: more needs: - job: exec_problem_3 artifacts: true script: - cd hw3/tests - make more3 - ./more3 > more3.txt - score="$(tail -n 1 more3.txt | tr -d '[:space:]')" - echo "$(cat more3.txt)" - echo "More-test score is $score" - STUDENT="$(echo "$CI_PROJECT_PATH" | sed -E 's#.*/HomeworkThree##')" - curl "https://agile.bu.edu/ec330_scripts/saveScores.pl?key=${MAGIC_KEY}&file=hw3_more3&name=${STUDENT}&score=${score}" artifacts: paths: - hw3/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3"' tags: [c++-17] efficiency_problem_3: stage: efficiency needs: - job: more_problem_3 artifacts: true script: - cd hw3/tests - make efficiency3 - set -o pipefail - | set +e timeout 180s stdbuf -oL ./efficiency3 > efficiency3.out STATUS=$? set -e context="$(tail -n 20 efficiency3.out | tail -c 500)" if [ "$STATUS" -eq 124 ]; then echo "Timeout!" exit 1 fi if [ "$STATUS" -eq 134 ] || [ "$STATUS" -eq 137 ]; then echo "Out of memory (status $STATUS) — aborted (134) or killed (137)" echo "Context: $context" exit 1 fi if [ "$STATUS" -ge 128 ] && [ "$STATUS" -le 192 ]; then sig=$((STATUS - 128)) echo "Crashed / terminated by signal $sig (exit $STATUS)" echo "Context: $context" exit 1 fi score="$(tail -n 1 efficiency3.out | tr -d '[:space:]')" - echo "$(cat efficiency3.out)" - echo "Efficiency score is $score" - STUDENT="$(echo "$CI_PROJECT_PATH" | sed -E 's#.*/HomeworkThree##')" - curl "https://agile.bu.edu/ec330_scripts/saveScores.pl?key=${MAGIC_KEY}&file=hw3_eff3&name=${STUDENT}&score=${score}" artifacts: paths: - hw3/ rules: - if: '$CI_COMMIT_REF_NAME == "problem3"' timeout: 5m tags: [c++-17] benchmark: stage: benchmark needs: - job: efficiency_problem_3 artifacts: true script: - git clone https://trachten-gitlab:${HW_INTERNAL}@agile.bu.edu/gitlab/ec330/ec330_staff/homeworks_internal/hw3_ec.git hw3_ec - cp impl/FullInteger.cpp hw3_ec/impl Loading
tests/Makefile +16 −4 Original line number Diff line number Diff line Loading @@ -6,23 +6,35 @@ CXXFLAGS = -std=c++17 # Source files PROBLEM3_SRCS = testFullInteger.cpp impl/FullInteger.cpp impl/IntegerPP.cpp impl/IntegerP.cpp impl/BigNum.cpp SRCS = $(PROBLEM3_SRCS) MORE3_SRCS = testMoreFullInteger.cpp impl/FullInteger.cpp impl/IntegerPP.cpp impl/IntegerP.cpp impl/BigNum.cpp EFFICIENCY3_SRCS = testEfficiencyFullInteger.cpp impl/RefFullInteger.cpp impl/FullInteger.cpp impl/IntegerPP.cpp impl/IntegerP.cpp impl/BigNum.cpp SRCS = $(PROBLEM3_SRCS) $(MORE3_SRCS) $(EFFICIENCY3_SRCS) # Object files PROBLEM3_OBJS = testFullInteger.o impl/FullInteger.o impl/IntegerPP.o impl/IntegerP.o impl/BigNum.o OBJS = $(PROBLEM3_OBJS) MORE3_OBJS = testMoreFullInteger.o impl/FullInteger.o impl/IntegerPP.o impl/IntegerP.o impl/BigNum.o EFFICIENCY3_OBJS = testEfficiencyFullInteger.o impl/RefFullInteger.o impl/FullInteger.o impl/IntegerPP.o impl/IntegerP.o impl/BigNum.o OBJS = $(PROBLEM3_OBJS) $(MORE3_OBJS) $(EFFICIENCY3_OBJS) # Executable name PROBLEM3_EXEC = problem3 EXECS = $(PROBLEM3_EXEC) MORE3_EXEC = more3 EFFICIENCY3_EXEC = efficiency3 EXECS = $(PROBLEM3_EXEC) $(MORE3_EXEC) $(EFFICIENCY3_EXEC) # Default target to build the executable all: $(PROBLEM3_EXEC) all: $(PROBLEM3_EXEC) $(MORE3_EXEC) $(EFFICIENCY3_EXEC) # Rule to build the executable from object files $(PROBLEM3_EXEC): $(PROBLEM3_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM3_EXEC) $(PROBLEM3_OBJS) $(MORE3_EXEC): $(MORE3_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(MORE3_EXEC) $(MORE3_OBJS) $(EFFICIENCY3_EXEC): $(EFFICIENCY3_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(EFFICIENCY3_EXEC) $(EFFICIENCY3_OBJS) # Rules to build object files from source files %.o: %.cpp Makefile $(CXX) $(CXXFLAGS) -c $< -o $@ Loading
tests/impl/RefFullInteger.cpp 0 → 100644 +36 −0 Original line number Diff line number Diff line // // Created by Ari on 2/22/26. // #include <iostream> #include <algorithm> #include <cmath> #include "../include/BigNum.h" #include "../include/RefFullInteger.h" using namespace std; // forward declaration unsigned int ithPrime(const size_t ii); bool RefFullInteger::operator<=(const FullInteger &other) const { double myLog = 0.0; auto myPrimes = primePowers(); for (int ii=0; ii<myPrimes[ii]; ++ii) { if (myPrimes[ii]!=0) myLog += myPrimes[ii] * log(ithPrime(ii)); } double otherLog = 0.0; auto otherPrimes = other.primePowers(); for (int ii=0; ii<otherPrimes.size(); ++ii) { if (otherPrimes[ii]!=0) otherLog += otherPrimes[ii] * log(ithPrime(ii)); } return myLog <= otherLog; } void RefFullInteger::limitedSort(vector<FullInteger>& nums, int largestPrimeFactor) { std::sort(nums.begin(), nums.end()); } No newline at end of file
tests/include/RefFullInteger.h 0 → 100644 +20 −0 Original line number Diff line number Diff line // // Created by Ari on 2/28/26. // #ifndef HW3_EC_REFFULLINTEGER_H #define HW3_EC_REFFULLINTEGER_H #include "FullInteger.h" class RefFullInteger:public FullInteger { public: RefFullInteger() = default; RefFullInteger(unsigned long n) : FullInteger(n) {} RefFullInteger(std::initializer_list<int> pBasis) : FullInteger(pBasis) {} RefFullInteger(vector<int> pBasis) { _primePowers = pBasis; } RefFullInteger(const IntegerP& other) : FullInteger(other) {} explicit RefFullInteger(const BigNum& num) : FullInteger(num) {} bool operator<=(const FullInteger &other) const; static void limitedSort(vector<FullInteger> &nums, int largestPrimeFactor); }; #endif //HW3_EC_REFFULLINTEGER_H No newline at end of file