diff --git a/Dockerfile b/Dockerfile index e6c43358762ad0d1191e90395bd29f2c2c061b8c..79905e4befffe117ac842a6a8f75324337de673f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,75 @@ -FROM python:3.7 +FROM ubuntu:20.04 +RUN apt-get update + +# Set up the basics (e.g., make, gcc and boost) +RUN apt-get install -y g++ make build-essential curl wget +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libboost-all-dev + +# Set Up Java +RUN apt-get install -y openjdk-11-jdk + +# Set up Rust +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" + +# Set up Python +RUN apt-get install -y python3 python3-pip +RUN pip3 install pylint pycodestyle pyhamcrest + +# Install C++ linters +RUN pip3 install cpplint + +#------------------------------------------------------------------------------- +# Set up quality of life tools +#------------------------------------------------------------------------------- + +# zsh +RUN apt-get install -y zsh + +ENV TERM xterm +ENV ZSH_THEME agnoster + +RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true + +# vim +RUN apt-get install -y vim + +# General tools +# RUN cargo install hyperfine +RUN wget https://github.com/sharkdp/hyperfine/releases/download/v1.9.0/hyperfine_1.9.0_amd64.deb +RUN dpkg -i hyperfine_1.9.0_amd64.deb + +# Copy in example code COPY . /cs417-examples WORKDIR /cs417-examples -#CMD ["python", "estimatePrecision.py", "10000", "16"] -CMD ["/bin/bash"] +#------------------------------------------------------------------------------- +# Time Dilation Examples +#------------------------------------------------------------------------------- +RUN make -C /cs417-examples/TimeDilation + +#------------------------------------------------------------------------------- +# Semester Project Input Libraries +#------------------------------------------------------------------------------- +RUN make -C /cs417-examples/SemesterProject-CPU-Temps/cpp +# RUN cd /cs417-examples/SemesterProject-CPU-Temps/java \ + # && bash ./gradlew build jar +# RUN make -C /cs417-examples/SemesterProject-CPU-Temps/python3 + +#------------------------------------------------------------------------------- +# Floating Point Precision Examples +#------------------------------------------------------------------------------- +# RUN make -C /cs417-examples/FPvsArbitraryPrecision/FP-ErrorEstimate-Python +RUN make -C /cs417-examples/FPvsArbitraryPrecision/FP-ErrorEstimate-C++ +RUN cd /cs417-examples/FPvsArbitraryPrecision/FP-ErrorEstimate-Rust \ + && cargo build +# RUN make -C /cs417-examples/SqrtExample + +#------------------------------------------------------------------------------- +# Monte Carlo Examples +#------------------------------------------------------------------------------- +#RUN make -C /cs417-examples/MonteCarloIntegration + +CMD ["zsh"] diff --git a/FPvsArbitraryPrecision/FP-ErrorEstimate-C++/cleveMoler.h b/FPvsArbitraryPrecision/FP-ErrorEstimate-C++/cleveMoler.h index 70a5c26b25b8780b5e443f3d1f07d6d357dc1cf1..5b973ed26ac638dff2bacb0cc389ae2d77187bb9 100644 --- a/FPvsArbitraryPrecision/FP-ErrorEstimate-C++/cleveMoler.h +++ b/FPvsArbitraryPrecision/FP-ErrorEstimate-C++/cleveMoler.h @@ -16,7 +16,7 @@ namespace std { */ inline float128 abs(float128 x) - { + { return signbit(x) ? changesign(x) : x; } } @@ -46,11 +46,13 @@ float128 estimatePrecision<float128>() { using T = float128; - T a = (4.0Q / 3.0Q); - T b = a - 1.0Q; + T ONE = float128{1.0}; + + T a = T{4.0} / T{3.0}; + T b = a - ONE; T c = b + b + b; - return std::abs(c - 1.0Q); + return std::abs(c - ONE); } #endif diff --git a/FPvsArbitraryPrecision/FP-ErrorEstimate-C++/makefile b/FPvsArbitraryPrecision/FP-ErrorEstimate-C++/makefile index 6cd8cad6952e9ecf13b02f3d73973ea497899794..42f3ef3a5a7ebbcae66218b5a0b2cf4f0308667f 100644 --- a/FPvsArbitraryPrecision/FP-ErrorEstimate-C++/makefile +++ b/FPvsArbitraryPrecision/FP-ErrorEstimate-C++/makefile @@ -2,7 +2,7 @@ MAINPROG=precisionEstimate SOURCES:=$(wildcard *.cpp) OBJECTS=$(SOURCES:.cpp=.o) -FLAGS=-std=c++17 -fsanitize=address -fuse-ld=gold -Wall -MMD \ +FLAGS=-std=c++2a -fuse-ld=gold -Wall -MMD \ -fext-numeric-literals -lquadmath -O0 all: $(SOURCES) $(MAINPROG) diff --git a/README.md b/README.md index bd55b4f68ea93a4b690c9a08a803dd82e711e188..e2e28f8d308bdf32dca79c00dcc695e7d3948389 100644 --- a/README.md +++ b/README.md @@ -39,4 +39,6 @@ compiler/interpreter, compilation instructions, and example commands. # Dockerfile -*Ignore the Docker file.* It is used for testing. +Run `docker build --tag 417-examples:0.1 .` to build the Docker image. + +Run `docker run -it 417-examples:0.1` to run the Docker image. diff --git a/SemesterProject-CPU-Temps/java/build.gradle b/SemesterProject-CPU-Temps/java/build.gradle index 48175637fbb21545feb2ffd0a3d753a42c9c7471..e5d9b234e380a4a0a30293fefcc55b54e72a83ae 100644 --- a/SemesterProject-CPU-Temps/java/build.gradle +++ b/SemesterProject-CPU-Temps/java/build.gradle @@ -1,32 +1,20 @@ buildscript { repositories { jcenter() - - // Add SpotBugs required repo - maven { - url "https://plugins.gradle.org/m2/" - } - } - - dependencies { - classpath "org.ysb33r.gradle:doxygen:0.2" - - // Add SpotBugs - classpath "gradle.plugin.com.github.spotbugs:gradlePlugin:1.6.0" } } -apply plugin: "java" -//apply plugin: "application" -apply plugin: "eclipse" -apply plugin: "org.ysb33r.doxygen" -apply plugin: "jacoco" +plugins { + id "java" + id "application" + id "eclipse" -apply plugin: "findbugs" -apply plugin: "pmd" -apply plugin: "com.github.spotbugs" - -apply plugin: "checkstyle" + id "checkstyle" + id "com.github.spotbugs" version "2.0.0" + id "project-report" + id "jacoco" + id "pmd" +} sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -35,6 +23,11 @@ repositories { jcenter() } +dependencies { + testCompile "junit:junit:4.12" + testCompile "org.hamcrest:hamcrest-library:1.3" +} + jar { baseName = "ParseTemps" @@ -48,16 +41,9 @@ jar { task deploy(dependsOn: [javadoc, check, jar]){ } -/** - * Run code style/error checks - */ -findbugsMain { - ignoreFailures true - reports { - xml.enabled false - html.enabled true - } -} +//------------------------------------------------------------------------------ +// Analysis Tools +//------------------------------------------------------------------------------ // SpotBugs spotbugsMain { @@ -74,7 +60,7 @@ spotbugsTest.enabled = false // End SpotBugs config jacoco { - toolVersion = "0.8.0" + toolVersion = "0.8.5" } jacocoTestReport { @@ -85,32 +71,6 @@ jacocoTestReport { } } -pmd { - ignoreFailures = true - ruleSets = [ - "java-basic", - "java-braces", - //"java-clone", - "java-codesize", - //"java-comments", - //"java-controversial", - //"java-coupling", - //"java-design", - "java-empty", - //"java-finalizers", - "java-imports", - //"java-junit", - "java-naming", - //"java-optimizations", - "java-strictexception", - "java-strings", - "java-sunsecure", - "java-typeresolution", - "java-unnecessary", - "java-unusedcode" - ] -} - // Check Style Config checkstyle { ignoreFailures = true @@ -124,3 +84,15 @@ tasks.withType(Checkstyle) { } checkstyleTest.enabled = false // End Checkstyle config + +pmd { + ignoreFailures = true + ruleSets = [ + "category/java/bestpractices.xml", + "category/java/codestyle.xml", + "category/java/design.xml", + "category/java/errorprone.xml", + "category/java/performance.xml" + ] +} + diff --git a/SemesterProject-CPU-Temps/java/gradle/wrapper/gradle-wrapper.properties b/SemesterProject-CPU-Temps/java/gradle/wrapper/gradle-wrapper.properties index 65cd6002ce596c597648f1dbc78e6a6fd57a7d1a..31e273ead545fba6233fd1fb64a4cd00e7a4d2dc 100644 --- a/SemesterProject-CPU-Temps/java/gradle/wrapper/gradle-wrapper.properties +++ b/SemesterProject-CPU-Temps/java/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip