BwUniCluster2.0/Software/R/stringi: Difference between revisions
No edit summary |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<span style="color:red"><b>Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)! |
<span style="color:red"><b>Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!</b></span> |
||
= General information = |
= General information = |
||
Line 23: | Line 23: | ||
</pre> |
</pre> |
||
Please run the following lines of code to set the appropriate flags, if necessary: |
|||
In this case, skip the following block of five commands. If this is not the case, enter the following commands in your shell (command line). |
|||
<pre> |
<pre> |
||
mkdir -p ~/.R |
mkdir -p ~/.R |
||
echo "CXX14= |
echo "CXX14=g++" > ~/.R/Makevars |
||
echo "CXX17= |
echo "CXX17=g++" >> ~/.R/Makevars |
||
echo " |
echo "CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option" >> ~/.R/Makevars |
||
echo " |
echo "CXX14FLAGS += -std=c++14" >> ~/.R/Makevars |
||
echo " |
echo "CXX17FLAGS += -std=c++17" >> ~/.R/Makevars |
||
echo "PKG_CXXFLAGS += -std=c++14 -wd308" >> ~/.R/Makevars |
|||
</pre> |
</pre> |
||
⚫ | |||
The installation of stringi makes use other libraries ([https://icu.unicode.org/ C/C++ and Java libraries for Unicode and globalization], icu4c Intel) which need to be loaded before installation (and R, of course). |
|||
We can now install <code>stringi</code> and its dependencies within a R session. To get the most out of <code>stringi</code>, you are strongly encouraged to rely on the custom ICU4C 74.1 implementation bundled with <code>stringi</code>: |
|||
<pre> |
<pre> |
||
module purge |
module purge |
||
module load math/R |
module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3 |
||
module load lib/icu4c/74.1_intel2021.4.0 |
|||
</pre> |
|||
⚫ | |||
⚫ | |||
We can now install stringi (in its development version) and its dependencies within a R session |
|||
⚫ | |||
<pre> |
|||
⚫ | |||
⚫ | |||
</pre> |
</pre> |
||
This ensures maximum portability across all platforms (Windows and macOS users fetch the pre-compiled binaries from CRAN built precisely this way). |
|||
== Testing the installation == |
== Testing the installation == |
||
Line 61: | Line 55: | ||
[1] 5 5 1 |
[1] 5 5 1 |
||
</pre> |
</pre> |
||
Note that you always need to load |
|||
<pre> |
|||
module load math/R/4.1.2 |
|||
module load lib/icu4c/74.1_intel2021.4.0 |
|||
</pre> |
|||
to your [[BwUniCluster_2.0_Slurm_common_Features#sbatch_Examples | batch job scripts]] that use stringi or to run them directly in the command line if you use an [[BwUniCluster_2.0_Batch_Queues | interactive session]]. |
Latest revision as of 18:17, 28 October 2024
Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!
General information
stringi
is an R
package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.
Installation
Please enter the code, presented in the boxes below, directly in your shell/command line on bwUniCluster:
Preparations
Prepare an .R/Makevars
file (if it does not already exist). This file specifies how R should compile the packages (i.e., sets some 'compiler flags').
If an .R/Makevars
file is present in your home directory ($HOME
), check whether the flags displayed below are set and apply adjustments, if necessary:
cat ~/.R/Makevars CXX14=g++ CXX17=g++ CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option CXX14FLAGS += -std=c++14 CXX17FLAGS += -std=c++17
Please run the following lines of code to set the appropriate flags, if necessary:
mkdir -p ~/.R echo "CXX14=g++" > ~/.R/Makevars echo "CXX17=g++" >> ~/.R/Makevars echo "CXXFLAGS = -O3 -fPIC -mavx -mavx2 -mavx512f -msse4.2 -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option" >> ~/.R/Makevars echo "CXX14FLAGS += -std=c++14" >> ~/.R/Makevars echo "CXX17FLAGS += -std=c++17" >> ~/.R/Makevars
Install the R package
We can now install stringi
and its dependencies within a R session. To get the most out of stringi
, you are strongly encouraged to rely on the custom ICU4C 74.1 implementation bundled with stringi
:
module purge module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3 R -q R> install.packages("stringi", configure.args="--disable-pkg-config")
This ensures maximum portability across all platforms (Windows and macOS users fetch the pre-compiled binaries from CRAN built precisely this way).
Testing the installation
To check whether the installation worked, make a test run in R
> library(stringi) > stri_length(c("Hello", "world", "!")) [1] 5 5 1