Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
BENCH_OPTS="--${{ matrix.bench_type }}" \
BENCH_OUT_DIR="$BENCH_OUT_DIR" \
BENCH_ITER="$BENCH_ITER" \
${{ matrix.bench_type == 'bc' && 'R_HOME=/R-vanilla' || '' }}
${{ matrix.bench_type == 'bc' && 'R=/usr/bin/R' || '' }}

- name: Copy results
run: |
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile.rcp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ ARG RSH_COMMIT=latest

FROM ghcr.io/prl-prg/rcp-rsh:${RSH_COMMIT}

RUN R -e 'install.packages("microbenchmark", repos="http://cran.r-project.org")'

ARG RCP_COMMIT
RUN --mount=type=ssh git clone git@github.com:PRL-PRG/rcp /rcp && \
git -C /rcp checkout --detach ${RCP_COMMIT} && \
git -C /rcp submodule update --init --depth 1 external/rsh

WORKDIR /rcp/rcp

RUN make
RUN make
35 changes: 24 additions & 11 deletions Dockerfile.rcp-base
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,28 @@ RUN apt update -y \

RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 14

# install vanilla R
# install vanilla R manually

RUN cd /tmp \
&& wget https://cran.r-project.org/src/base/R-4/R-4.3.2.tar.gz \
&& tar -xzf R-4.3.2.tar.gz \
&& cd R-4.3.2 \
&& ./configure --prefix=/R-vanilla \
&& make -j$(nproc) \
&& make install \
&& cd / \
&& rm -rf /tmp/R-4.3.2* \
&& /R-vanilla/bin/R -e 'install.packages("microbenchmark", repos="https://cloud.r-project.org")'
# ARG R_VERSION=4.3.2
#
# flags from the R CMD config on ubuntu 24.04 and r-base 4.3.3-2build2
# ARG CFLAGS="-O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=3"
# ARG FFLAGS="-O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fstack-protector-strong -fstack-clash-protection -fcf-protection"
# ARG FCFLAGS="-O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fstack-protector-strong -fstack-clash-protection -fcf-protection"
# ARG LDFLAGS="-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro"
#
# RUN set -eux; \
# cd /tmp \
# && wget https://cran.r-project.org/src/base/R-${R_VERSION%%.*}/R-${R_VERSION}.tar.gz \
# && tar -xzf R-${R_VERSION}.tar.gz \
# && cd R-${R_VERSION} \
# && CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" FFLAGS="$FFLAGS" FCFLAGS="$FCFLAGS" ./configure --prefix=/R-vanilla \
# && make -j"$(nproc)" \
# && make install \
# && cd / \
# && rm -rf /tmp/R-${R_VERSION}* \
# && /R-vanilla/bin/R -e 'install.packages("microbenchmark", repos="https://cloud.r-project.org")'

# install vanilla R which comes with Ubuntu
RUN apt install -y r-base && \
R -e 'install.packages("microbenchmark", repos="https://cloud.r-project.org")'
5 changes: 3 additions & 2 deletions Dockerfile.rcp-rsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ RUN --mount=type=ssh git clone git@github.com:PRL-PRG/r-compile-server.git /rsh
RUN cd /rsh && \
bash -x ./tools/build-gnur.sh external/R

ENV R_HOME=/rsh/external/R
ENV PATH="${PATH}:${R_HOME}/bin"
ENV RSH_R_HOME=/rsh/external/R

RUN "$RSH_R_HOME/bin/R" -e 'install.packages("microbenchmark", repos="https://cloud.r-project.org")'
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
DOCKER_IMAGE_ORG := prl-prg
DOCKER_IMAGE_ORG := ghcr.io/prl-prg
DOCKER_BUILD_CMD := DOCKER_BUILDKIT=1 docker build --ssh default

RSH_COMMIT ?= $(shell git -C external/rsh rev-parse HEAD)
RCP_COMMIT ?= $(shell git rev-parse HEAD)

all: docker-rcp

.PHONY: docker-rcp-base
docker-rcp-base:
$(DOCKER_BUILD_CMD) \
Expand All @@ -20,4 +22,4 @@ docker-rcp: docker-rcp-rsh
$(DOCKER_BUILD_CMD) \
--build-arg RSH_COMMIT=$(RSH_COMMIT) \
--build-arg RCP_COMMIT=$(RCP_COMMIT) \
-t $(DOCKER_IMAGE_ORG)/rcp:$(RCP_COMMIT) -f Dockerfile.rcp .
-t $(DOCKER_IMAGE_ORG)/rcp:$(RCP_COMMIT) -f Dockerfile.rcp .
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copy and Patch JIT compilation for R

This repository contains the code neccessary to run Copy and Patch JIT for R.
This repository contains the code necessary to run Copy and Patch JIT for R.

## Installation

Expand Down
18 changes: 9 additions & 9 deletions rcp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ EXTRACTED_DIR = $(BUILD_DIR)/extracted
R_PACKAGE = $(BUILD_DIR)/rcp_1.0.0.0000.tar.gz
R_PACKAGE_SOURCE = $(shell find $(ROOT_DIR)/r-pkg/*)
RSH_HOME = $(ROOT_DIR)/../external/rsh/client/rsh
R_HOME ?= $(ROOT_DIR)/../external/rsh/external/R
R_LIB = $(R_HOME)/library/rcp/libs/rcp.so
RSH_R_HOME ?= $(ROOT_DIR)/../external/rsh/external/R
RCP_LIB = $(RSH_R_HOME)/library/rcp/libs/rcp.so

# 0 = relative addressing, 1 = relative addressing with GOT where needed, 2 = absolute addressing
RELOC_MODEL ?= 1
Expand Down Expand Up @@ -56,7 +56,7 @@ endif
$(STENCILS_OBJ): stencils/stencils.c
@echo "Building stencils..."
mkdir -p build
$(CC) stencils/stencils.c -o $(STENCILS_OBJ) -c -ffunction-sections -fno-stack-protector -fcf-protection=none -fno-asynchronous-unwind-tables -Os -fno-pic -mcmodel=$(MCMODEL) -fno-math-errno -fno-trapping-math -fno-merge-constants -fno-jump-tables -fno-align-functions -fno-align-jumps -fno-align-labels -I$(R_HOME)/include -I$(RSH_HOME)/src/bc2c $(DEFINE_FLAGS) $(C_FLAGS_ADDITIONAL)
$(CC) stencils/stencils.c -o $(STENCILS_OBJ) -c -ffunction-sections -fno-stack-protector -fcf-protection=none -fno-asynchronous-unwind-tables -Os -fno-pic -mcmodel=$(MCMODEL) -fno-math-errno -fno-trapping-math -fno-merge-constants -fno-jump-tables -fno-align-functions -fno-align-jumps -fno-align-labels -I$(RSH_R_HOME)/include -I$(RSH_HOME)/src/bc2c $(DEFINE_FLAGS) $(C_FLAGS_ADDITIONAL)
# -fno-align-loops

$(EXTRACTOR_BIN): extractor/extract_stencils.c
Expand All @@ -72,17 +72,17 @@ $(R_PACKAGE): $(STENCILS_OBJ) $(EXTRACTOR_BIN)# $(R_PACKAGE_SOURCE)
ln -sfn $(EXTRACTED_DIR) $(ROOT_DIR)/r-pkg/src/stencils
ln -s $(RSH_HOME)/src/bc2c/runtime_internals.h $(ROOT_DIR)/r-pkg/src/runtime_internals.h
ln -s $(ROOT_DIR)/rcp_common.h $(ROOT_DIR)/r-pkg/src/rcp_common.h
cd $(BUILD_DIR) && $(R_HOME)/bin/R CMD build ../r-pkg
cd $(BUILD_DIR) && $(RSH_R_HOME)/bin/R CMD build ../r-pkg
rm -f $(ROOT_DIR)/r-pkg/src/rcp_common.h
rm -f $(ROOT_DIR)/r-pkg/src/runtime_internals.h
rm -f $(ROOT_DIR)/r-pkg/src/stencils

$(R_LIB): $(R_PACKAGE)
$(RCP_LIB): $(R_PACKAGE)
@echo "Installing package..."
cd build && MCMODEL=$(MCMODEL) SPECIALIZE_STEPFOR=$(SPECIALIZE_STEPFOR) SPECIALIZE_MATH1=$(SPECIALIZE_MATH1) ALIGNMENT_LABELS=$(ALIGNMENT_LABELS) ALIGNMENT_JUMPS=$(ALIGNMENT_JUMPS) ALIGNMENT_LOOPS=$(ALIGNMENT_LOOPS) $(R_HOME)/bin/R CMD INSTALL rcp_1.0.0.0000.tar.gz
cd build && MCMODEL=$(MCMODEL) SPECIALIZE_STEPFOR=$(SPECIALIZE_STEPFOR) SPECIALIZE_MATH1=$(SPECIALIZE_MATH1) ALIGNMENT_LABELS=$(ALIGNMENT_LABELS) ALIGNMENT_JUMPS=$(ALIGNMENT_JUMPS) ALIGNMENT_LOOPS=$(ALIGNMENT_LOOPS) $(RSH_R_HOME)/bin/R CMD INSTALL rcp_1.0.0.0000.tar.gz

.PHONY: install
install: $(R_LIB)
install: $(RCP_LIB)


BENCH_ITER ?= 15
Expand All @@ -95,14 +95,14 @@ TXT_NORM = \033[0m
TXT_GREEN = \033[0;32m
TXT_RED = \033[0;31m

R ?= $(R_HOME)/bin/R
R ?= $(RSH_R_HOME)/bin/R
BENCH_DIR = $(RSH_HOME)/inst/benchmarks
HARNESS_BIN = harness.R
FILTER ?=

.PHONY: run
run: install
@$(R_HOME)/bin/R
@$(RSH_R_HOME)/bin/R

.PHONY: benchmark
benchmark:
Expand Down