1

I am struggling my way through making daal work in my project, and have now come across the following error - I am struggling to make any sense of it and not quite sure where to even start with debugging.

I am trying to replicate this website's code: https://www.codeproject.com/Articles/1151606/Lightning-Fast-R-Machine-Learning-Algorithms but in Windows 10, and have the following software (exactly as per the website):

  • Intel DAAL 2017 Beta update 1
  • R version 3.3.1 (Bug in Your Hair)
  • Rcpp package version 0.12.5
  • Inline package version 0.3.14
  • e1071 package version 1.6-7

I have done the following:

The following is the error I am getting - please help me someone as I am struggling!

        file473877c213b9.cpp: In function 'SEXPREC* file473877c213b9(SEXP, SEXP)':
        file473877c213b9.cpp:37:49: error: incomplete universal character name \U
              std::string fname = Rcpp::as<std::string>(-"C:\Users\Documents\BAJAJ.csv");
                                                     ^
    file473877c213b9.cpp:37:49: warning: unknown escape sequence: '\D'
    file473877c213b9.cpp:37:49: warning: unknown escape sequence: '\B'
    file473877c213b9.cpp:37:49: error: wrong type argument to unary minus
    file473877c213b9.cpp:38:29: error: no matching function for call to 'as(int)'
          int k = Rcpp::as<int>(7);
---------------------------------------------------------------------------------

        make: *** [file473877c213b9.o] Error 1
    Warning message:
    running command 'make -f "C:/R/R-33~1.1/etc/x64/Makeconf" -f "C:/R/R-33~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file473877c213b9.dll" WIN=64 TCLBIN=64 OBJECTS="file473877c213b9.o"' had status 2 
---------------------------------------------------------------------------------

    Error in compileCode(f, code, language = language, verbose = verbose) : 
      Compilation ERROR, function(s)/method(s) not created! In file included from file3f9022477144.cpp:3:0:
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:25:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
     #pragma warning(disable:809)
     ^
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:38:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
         #pragma comment(lib, "tbb.lib" )
     ^
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:39:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
         #pragma comment(lib, "tbbmalloc.lib" )
     ^
    In file included from C:/R/R-33~1.1/include/data_management/data/data_dictionary.h:35:0,
                     from C:/R/R-33~1.1/include/data_management/data_source/data_source.h:33,
                     from C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\in
    In addition: Warning message:
    running command 'C:/R/R-33~1.1/bin/x64/R CMD SHLIB file3f9022477144.cpp 2> file3f9022477144.cpp.err.txt' had status 1 

Many thanks in advance for any help anyone can provide (i'm not a coder so am struggling!)

Keyur


edit 21 July 2018 - excerpts of my code to provide further details

library(Rcpp)
library(inline)

# Create and register a Rcpp plugin
plug <- Rcpp:::Rcpp.plugin.maker(
     include.before = "#include <C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.1.143\\windows\\daal\\include\\daal.h> ",
     libs = paste("/Qdaal[-C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.1.143\\windows\\daal\\lib\\intel64_win\\daal_core.lib]",
         "/Qdaal[-C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.1.143\\windows\\daal\\lib\\intel64_win\\daal_thread.lib]", sep=""))
registerPlugin("daalNB", plug)


# load data
readCSV <- '
     using namespace daal;
     using namespace daal::data_management;

     // Inputs:
     // file - file name
     // ncols - number of columns in file
     std::string fname = Rcpp::as<std::string>("C://Users//Documents//BAJAJ.csv");
     int k = Rcpp::as<int>(7);......***rest of the code as per the website referenced above, ie same code for the readCSV, train and predict functions***

Functions to actually call the functions:

# R function for loading data and labels
loadData <- cxxfunction(signature(file="character", ncols="integer"),readCSV, plugin="daalNB")

# R function for training a model
nbTrain <- cxxfunction(signature(X="raw", y="raw", nclasses="integer"),
                       train, plugin="daalNB")

# R function for scoring
nbPredict <- cxxfunction(signature(model="raw", X="raw", nclasses="integer"),
                         predict, plugin="daalNB")

The errors I am getting in relation to the readCSV <- function:

C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/as.h:151:29: note:   template argument deduction/substitution failed:
file40e81ac24329.cpp:36:89: note:   cannot convert '"C://Users//Documents//BAJAJ.csv"' (type 'const char [40]') to type 'SEXP'
      std::string fname = Rcpp::as<std::string>("C://Users//Documents//BAJAJ.csv");
                                                                                         ^
file40e81ac24329.cpp:37:29: error: no matching function for call to 'as(int)'
      int k = Rcpp::as<int>(7);

make: *** [file40e81ac24329.o] Error 1
Warning message:
running command 'make -f "C:/R/R-33~1.1/etc/x64/Makeconf" -f "C:/R/R-33~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file40e81ac24329.dll" WIN=64 TCLBIN=64 OBJECTS="file40e81ac24329.o"' had status 2 

ERROR(s) during compilation: source code errors or compiler configuration errors!

The below error summmary appears in red in the R Studio console:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from file40e81ac24329.cpp:3:0:
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:25:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:809)
 ^
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:38:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
     #pragma comment(lib, "tbb.lib" )
 ^
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\include\daal.h:39:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
     #pragma comment(lib, "tbbmalloc.lib" )
 ^
In file included from C:/R/R-33~1.1/include/data_management/data/data_dictionary.h:35:0,
                 from C:/R/R-33~1.1/include/data_management/data_source/data_source.h:33,
                 from C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.1.143\windows\daal\in
In addition: Warning message:
running command 'C:/R/R-33~1.1/bin/x64/R CMD SHLIB file40e81ac24329.cpp 2> file40e81ac24329.cpp.err.txt' had status 1

Edit - 23 July 2018

I made the changes to the csv path as suggested by Ralf, and also inserted the following in the Makevars.win file:

CXX=C:/IntelSWTools2018/compilers_and_libraries_2018.3.210/windows/bin/intel64/icl.exe

CXXFLAGS=-I"C:/IntelSWTools2018/compilers_and_libraries_2018.3.210/windows/daal/include" -I"C:/IntelSWTools2018/compilers_and_libraries_2018.3.210/windows/compiler/include" -I"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt" -I"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include

Now am getting the following errors:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0.3.210 Build 20180410
Copyright (C) 1985-2018 Intel Corporation.  All rights reserved.

icl: NOTE: The evaluation period for this product ends on 4-aug-2018 UTC.
compilation aborted for file35d0134c2a9d.cpp (code 2)
make: *** [file35d0134c2a9d.o] Error 2
Warning message:
running command 'make -f "C:/R/R-33~1.1/etc/x64/Makeconf" -f "C:/R/R-33~1.1/share/make/winshlib.mk" -f "C:/Users/Documents/.R/Makevars.win" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file35d0134c2a9d.dll" WIN=64 TCLBIN=64 OBJECTS="file35d0134c2a9d.o"' had status 2 
In addition: Warning message:
running command 'C:/R/R-33~1.1/bin/x64/R CMD SHLIB file35d0134c2a9d.cpp 2> file35d0134c2a9d.cpp.err.txt' had status 1

I can see a few lines in the code which suggest some issues, but cant make head or tail of these:

C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/xmmintrin.h(61): error #2277: invalid definition of __m128; use #include "xmmintrin.h" instead
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/xlocale(341): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/xlocale(367): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/internal/NAComparator.h(62): error: expected a ")"
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/r_cast.h(32): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/module/Module_generated_CppFunction.h(53): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/module/Module_generated_CppFunction.h(93): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/api/meat/module/Module.h(40): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Users/Documents/R/win-library/3.3/Rcpp/include/Rcpp/api/meat/module/Module.h(40): warning #583: C++ exception handler found but /EHsc option was not specified
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/xstring(2195): warning #583: C++ exception handler found but /EHsc option was not specified

Edit 25 July 2018

Have now gone back to the exact packages daal versions noted in the website (very old!), and changed the CSV path as per Ralf's suggestion, and am getting the following compilation errors:

    Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file2ddc1463da6.o:file2ddc1463da6.cpp:(.text+0x2e6): undefined reference to `daal::data_management::interface1::SerializationIface::serialize(daal::data_management::interface1::InputDataArchive&)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text+0x304): undefined reference to `daal::data_management::interface1::SerializationIface::serialize(daal::data_management::interface1::InputDataArchive&)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacenwEy[_ZN4daal15data_management10interface118SerializationIfacenwEy]+0x16): undefined reference to `daal::services::daal_malloc(unsigned long long, unsigned long long)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacenaEy[_ZN4daal15data_management10interface118SerializationIfacenaEy]+0x16): undefined reference to `daal::services::daal_malloc(unsigned long long, unsigned long long)'
fi

The source of these are a tonne of lines such as:

file2ddc1463da6.o:file2ddc1463da6.cpp:(.text+0x2e6): undefined reference to `daal::data_management::interface1::SerializationIface::serialize(daal::data_management::interface1::InputDataArchive&)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text+0x304): undefined reference to `daal::data_management::interface1::SerializationIface::serialize(daal::data_management::interface1::InputDataArchive&)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacenwEy[_ZN4daal15data_management10interface118SerializationIfacenwEy]+0x16): undefined reference to `daal::services::daal_malloc(unsigned long long, unsigned long long)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacenaEy[_ZN4daal15data_management10interface118SerializationIfacenaEy]+0x16): undefined reference to `daal::services::daal_malloc(unsigned long long, unsigned long long)'
file2ddc1463da6.o:file2ddc1463da6.cpp:(.text$_ZN4daal15data_management10interface118SerializationIfacedlEPvy[_ZN4daal15data_management10interface118SerializationIfacedlEPvy]+0x15): undefined reference to `daal::services::daal_free(void*)'
KKel
  • 61
  • 6
  • Which compiler do you use? Are you sure this is the full error message? – Ralf Stubner Jul 20 '18 at 13:31
  • Hi Ralf - i was using the one that has come with RTools 3.3, which I believe is mingw. I will update the above with more of the errors. Should i be using a different compiler? Though I am not sure how to change the compiler / and to call it in the R code per the website link – KKel Jul 20 '18 at 17:05
  • The compiler is old but should be fine. The tutorial you are using could use an update, but that’s not the problem. Concerning the error messages: Use `/` instead of `\` in the path and remove any leading `-`. If this is not enough, please include the code you use for calling the function together with the new error messages. – Ralf Stubner Jul 21 '18 at 05:02
  • Hi Ralf - many thanks for your help thus far. I have updated the excerpts of my code and the error above, would you mind having a quick look? Happy to pay for your time and to arrange a screen share if possible? – KKel Jul 21 '18 at 08:24

1 Answers1

1

The Rcpp::as function you use is needed to convert between an R internal data type (SEXP) and normal C++ data types (int, string, ...). This is needed when you pass arguments from R to your C++ function. Since you specify the parameter in the C++ code, you do not need this function. The following should work in your readCsv function:

std::string fname = "C:/Users/Documents/BAJAJ.csv";
int k = 7;

Alternatively you can stick to the version from the tutorial where these parameters are passed in from R.

BTW, you don’t need to double /. Only \ has a special meaning and has to be doubled to refer to the literal version.

Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75
  • many thanks Ralf - am edging my way to a solution - have come across a different error now it seems (updated in the above post) – KKel Jul 23 '18 at 04:58
  • @KKel Tricky. Can you compile a trivial Rcpp function with the Intel compiler but without referencing DAAL? – Ralf Stubner Jul 23 '18 at 13:05
  • thanks Ralf - was able to do trivial function and feel like i am close to a solution - but have come up with a few more compile errors (updated in the 25 July section above)...will appreciate any further ideas – KKel Jul 25 '18 at 14:03
  • @KKel This probably means that the linking parameters are not correct. These are specified in the `inline` plugin with a syntax appropriate for `gcc`. The Intel compiler probably needs a different syntax to link to the `daal` library. – Ralf Stubner Jul 25 '18 at 14:52