Skip to content

Commit

Permalink
drop C++11 features which seem very difficult to make work with OpenM…
Browse files Browse the repository at this point in the history
…P in a way acceptable to CRAN.
  • Loading branch information
Jack O. Wasey committed Mar 15, 2015
1 parent 790304f commit bc8fe38
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: Calculate comorbidities, Charlson scores, perform fast and accurate
hospital billing databases to comorbidities. ICD-9 to comorbidity mappings
from Quan (Deyo and Elixhauser versions), Elixhauser and AHRQ included.
Version: 1.1
Date: 2015-03-08
Date: 2015-03-14
Authors@R: person(given = "Jack O.", family = "Wasey",
role = c("aut", "cre", "cph"),
email = c("jack@jackwasey.com"))
Expand Down
2 changes: 1 addition & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Resubmission
* removed tr1/unordered_map include, replaced with Makevars C++11 flags per Writing R Extensions 1.2.4, and tested for C++11 before choice of std::unordered_map or std::map depending on availability.
* now I better understand 1.2.1.1 of Writing R Extensions (specifically that adding the C++11 flag constitutes using a C++11 compiler), and given my current inability to write a configure script, this resubmission drops all C++11 code and flags.

## Test environments
* Ubuntu 14.10 R 3.1.3, clang and gcc
Expand Down
5 changes: 3 additions & 2 deletions src/Makevars
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
CXX_STD = CXX11
# CXX_STD = CXX11
# PKG_CXXFLAGS += $(CXX1XSTD) # on hold until CRAN will accept this (or I figured out how to write a configure script to generate this Makefile)

PKG_CPPFLAGS = -I.
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) $(CXX1XSTD)
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS)

Expand Down
9 changes: 4 additions & 5 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
CXX_STD = CXX11
# CXX_STD = CXX11
# $(CXX1XSTD)

PKG_CPPFLAGS = -I.
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) $(CXX1XSTD) -mtune=native
PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) -mtune=native
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS)

#CXX_STD = CXX11 # note that this trashes my choice of compiler reverting to g++ instead of clang
8 changes: 4 additions & 4 deletions src/comorbidSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ void buildVisitCodesVec(const SEXP& icd9df, const std::string& visitId,
const int approx_cmb_per_visit = 15; // just an estimate
int vlen = Rf_length(icds); // or vsexp

#if defined(ICD9_DEBUG) && defined(_GLIBCXX_UNORDERED_MAP)
Rcout << "unordered_map is available\n";
#endif
//#if defined(ICD9_DEBUG) && defined(ICD9_UNORDERED_MAP)
// Rcout << "unordered_map is available\n";
//#endif
VisLk vis_lookup;

vcdb.resize(vlen); // over-estimate and allocate all at once (alternative is to reserve)
Expand Down Expand Up @@ -64,7 +64,7 @@ void buildVisitCodesVec(const SEXP& icd9df, const std::string& visitId,
if (lastVisitId != vi) {
// assume new visitId unless aggregating
vcdb_new_idx = vcdb_max_idx + 1;
if (aggregate) { // only use unordered_map if aggregating
if (aggregate) { // only use map if aggregating
VisLk::iterator found = vis_lookup.find(vi); // TODO make const?
if (found != vis_lookup.end()) {
vcdb[found->second].push_back(n);
Expand Down
14 changes: 7 additions & 7 deletions src/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ extern "C" {
#define ICD9_OPENMP
#endif

// enable linux performance counting
#ifdef ICD9_VALGRIND
#include <valgrind/callgrind.h>
#endif
Expand All @@ -44,17 +43,18 @@ typedef std::vector<Str> VecStr;

typedef std::vector<int> VecInt;
typedef std::vector<char> ComorbidOut; // TODO: someday benchmark int vs char (or possibly Boost bitset)
// vector<bool> dangerous with multiple threads, and note that char doesn't cast to bool with Rcpp
// vector<bool> dangerous with multiple threads, and note that char doesn't cast to bool (directly) with Rcpp, yet.

typedef std::vector<VecStr> VecVecStr;
typedef std::vector<VecInt> VecVecInt;
typedef VecVecInt::size_type VecVecIntSz;
#ifdef _GLIBCXX_UNORDERED_MAP
#include <unordered_map>
typedef std::unordered_map<std::string, VecInt::size_type> VisLk;
#else
//#if defined(_GLIBCXX_UNORDERED_MAP) && defined(__GXX_EXPERIMENTAL_CXX0X__)
//#define ICD9_UNORDERED_MAP
//#include <unordered_map>
//typedef std::unordered_map<std::string, VecInt::size_type> VisLk;
//#else
typedef std::map<std::string, VecInt::size_type> VisLk;
#endif
//#endif

void buildMap(const Rcpp::List& icd9Mapping, VecVecInt& map);
void buildVisitCodesVec(const SEXP& icd9df, const std::string& visitId,
Expand Down

0 comments on commit bc8fe38

Please sign in to comment.