Skip to content

Commit

Permalink
Added myomp.h (#2473)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdowle authored Nov 10, 2017
1 parent 862df78 commit f75e8ee
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CRAN_Release.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ tar xvf R-devel.tar.gz
cd R-devel
# Following R-exts#4.3.3
# (clang 3.6.0 works but gcc 4.9.2 fails in R's distance.c:256 error: ‘*.Lubsan_data0’ not specified in enclosing parallel)
./configure CC="clang-5.0 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero -fno-omit-frame-pointer" CFLAGS="-g -O0 -Wall -pedantic" --without-recommended-packages --disable-byte-compiled-packages
./configure CC="clang-5.0 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero -fno-omit-frame-pointer" CFLAGS="-g -Og -Wall -pedantic" --without-recommended-packages --disable-byte-compiled-packages
make
alias Rdevel='~/build/R-devel/bin/R --vanilla'
Rdevel
install.packages("bit64") # important to run tests using integer64
# Skip compatibility tests with other Suggests packages; unlikely UBSAN/ASAN problems there.
q("no")
Rdevel CMD INSTALL ~/data.table_1.10.1.tar.gz
Rdevel CMD INSTALL data.table_1.10.5.tar.gz
# Check UBSAN and ASAN flags appear in compiler output above. Rdevel was compiled with
# them (above) so should be passed through to here
Rdevel
Expand Down
7 changes: 1 addition & 6 deletions src/data.table.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#include <R.h>
#define USE_RINTERNALS
#include <Rinternals.h>
#ifdef _OPENMP
#include <omp.h>
#else // so it still compiles on machines with compilers void of openmp support
#define omp_get_num_threads() 1
#define omp_get_thread_num() 0
#endif
// #include <signal.h> // the debugging machinery + breakpoint aidee
// raise(SIGINT);
#include <stdint.h> // for uint64_t rather than unsigned long long
#include "myomp.h"

// data.table depends on R>=3.0.0 when R_xlen_t was introduced
// Before R 3.0.0, RLEN used to be switched to R_len_t as R_xlen_t wasn't available.
Expand Down
4 changes: 1 addition & 3 deletions src/fread.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
#include <stdint.h> // uint32_t
#include <stdlib.h> // size_t
#include <stdbool.h> // bool
#include "myomp.h"
#ifdef DTPY
#include "myomp.h"
#include "py_fread.h"
#else
#include <omp.h>
#include "freadR.h"
#endif


// Ordered hierarchy of types
typedef enum {
NEG = -1, // dummy to force signed type; sign bit used for out-of-sample type bump management
Expand Down
2 changes: 1 addition & 1 deletion src/fwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define WRITE write
#define CLOSE close
#endif
#include <omp.h>
#include "myomp.h"
#include "fwrite.h"

#define NUM_SF 15
Expand Down
9 changes: 9 additions & 0 deletions src/myomp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef _OPENMP
#include <omp.h>
#else
// for machines with compilers void of openmp support
#define omp_get_num_threads() 1
#define omp_get_thread_num() 0
#define omp_get_max_threads() 1
#endif

0 comments on commit f75e8ee

Please sign in to comment.