Giter VIP home page Giter VIP logo

wll-interface's People

Contributors

halirutan avatar njpipeorgan avatar samuelpmish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wll-interface's Issues

crash with wll::list<double> as input

First of all, thanks for sharing this amazing project! This project is not only very useful in practice to ease the interaction of C++ in Mathematica, it also demonstrates greate C++ programming skills of implementing the whole system compactly.

When running in ubuntu 18.04, the sum of an array example doesn't seem to work for me. It crashes the Mathematica kernel.

This is the process I used to build and load the library in Mathematica:

<<CCompilerDriver`
CCompilerDriver`$CCompiler={
"Compiler"->CCompilerDriver`GenericCCompiler`GenericCCompiler,
"CompilerInstallation"->"/usr/bin","CompilerName"->"g++-7"};

src="
#include <numeric>
#include \"wll_interface.h\"
double sum(const wll::list<double>& a)
{
    return std::accumulate(a.begin(), a.end(), 0.0);
}
DEFINE_WLL_FUNCTION(sum)";

mylib=CreateLibrary[src,"wll_sum",
"IncludeDirectories"->{"/root/wll-interface/include"},
"CompileOptions"->"-std=c++17 -fPIC"]

mylib=CreateLibrary[src,"wll_sum",
"IncludeDirectories"->{"/root/wll-interface/include"},
"CompileOptions"->"-std=c++17 -fPIC"]
sum = LibraryFunctionLoad[mylib, "wll_sum", {{Real, 1, "Constant"}}, Real];
sum[{1,2,3}]

I'm using gcc 7.4 on ubuntu 18.04: g++-7 (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

Do you have any ideas or suggestions for the potential cause?
Thanks.

Crash when loading external library

It seems that calling an external library in a library function leads to crash of mathematica kernals.

These are the steps to reproduce the crash:

File /tmp/external_lib/addone.c:

int addone(int x){
    return x+1;
}

Compile to dynamic library

gcc -Wall -fpic -shared -o libaddone.so addone.c

which generate file /tmp/external_lib/libaddone.so

Load into Mathematica

src = "
  #include <wll_interface.h>
  int addone(int x);
  int test(int x)
  {
  	return addone(x);
  }
  DEFINE_WLL_FUNCTION(test)";

CCompilerDriver`$CCompiler = {"Compiler" -> 
   CCompilerDriver`GenericCCompiler`GenericCCompiler, 
  "CompilerInstallation" -> "/usr/bin", "CompilerName" -> "g++-7"}

mylib = CreateLibrary[src, "wll_test", 
  "IncludeDirectories" -> {"/home/mengxiwu/.Mathematica/include"}, 
  "LibraryDirectories" -> {"/tmp/external_lib/"}, 
  "CompileOptions" -> "-std=c++17 -fPIC", 
  "LinkerOptions" -> "-laddone"]

test = LibraryFunctionLoad[mylib, "wll_test", {Integer}, Integer]
test[3]

Any ideas for the crash? Thanks.

question about returning by reference + `PackedArray`

Thank you for developing wll-interface, it's been incredibly useful in my personal projects. My question is:

Is there a way to return a wll::tensor by-reference if the dimensions are not known a priori?

Right now, I'm splitting up any C++ routines that have multiple returns into:

  • one function that calculates the outputs and writes them to some global variable
  • "getters" that access that global and return each output individually

Returning multiple things by-reference would be cleaner and thread-safe, but when I tried it, my C++ functions that resized the by-reference output wll::tensors caused the kernel to crash.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.