GithubHelp home page GithubHelp logo

ahbarnett / multilingual-julia Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 1.0 68 KB

Minimally complete examples of Julia calling, more importantly being called by, Fortran, C, and Python.

Fortran 10.69% Julia 18.49% Makefile 7.68% C 57.54% Python 5.61%

multilingual-julia's Introduction

multilingual-julia

Minimally complete examples of interfacing between Julia and various languages, including the uncommon and undocumented case of Fortran calling Julia. Interoperability between languages is essential if Julia is to integrate with scientific codebases in Fortran, C, and Python. One cannot always assume that Julia will be the top-level/driver environment. Libraries written in Julia should be able to be called by Fortran/C/Py users. This motivates this simple set of tutorial examples. Please help by expanding it.

The focus is:

  • calling user-written Julia functions from C/Fortran
  • passing arrays (their allocation being on the C/Fortran side)
  • using multithreading

They are tested in a linux environment only (Ubuntu 21.04, GCC10, Julia 1.7.1).

Thanks to: Julia docs, StackOverflow, Julia Discourse, especially to Steven G Johnson.

Contents

jcallf : Julia calls Fortran (ie, wrapping low-level language functions)
ccallj : C calls Julia ("embedding")
fcallj : Fortran calls Julia ("embedding", but needs intermediate C layer)
pcallj : Python calls Julia (needs various Py and Jl packages, see makefile)

Each directory has its own makefile, which read any common settings placed in the top-level file make.inc (thus, you will need to copy make.inc.example to this file). Some demos explore multithreading in the "inner" (called) function. Some also report timings (which adds a few lines of code beyond the "minimal").

There are notes and resource links in each directory.

Requirements

Recent Julia installed, C complier, Fortran compiler, GNU make.

Testing

  1. cp make.inc.example make.inc

  2. Edit make.inc for your Julia installation directory and choice of compilers

  3. make

This goes to each directory and makes/runs all examples. Total wall-clock time is around 30 seconds, a lot due to Julia first-run times.

To do

  • J calling F with non-void return type, eg ddot LAPACK in manual 27.5

  • J calling C, eg w/ SIMD (manual has it); 27.14 thread safety I don't get

  • understand garbage collection in the C calling J case (Manual 30.5)

  • passing function handles in either direction (probably hard)

multilingual-julia's People

Contributors

ahbarnett avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

agnes-riviere

multilingual-julia's Issues

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.