Getting Started with Perl Bindings - Calling C/C++/Cuda

An introduction to Perl bindings. Binding means that you can call source code written in C language/C++/Cuda etc. from Perl from Perl.

You can get the best performance by writing your code in C or C++. When the performance of numerical calculation and array calculation is important such as image processing, video processing, signal processing, scientific and technological calculation, machine learning, binding C language or C++ library from Perl is a good solution. This is one of the measures.

In recent years, GPU has been used for parallel computation in deep learning, but the Cuda language for using GPU And binding is also possible. It is compiled by a compiler called nvcc, but the C language/C++ notation is adopted.

Binding using XS

There is a binding method using XS. This is the most standard method in Perl. Type conversion requires you to manually remember the XS API and create it as a Perl module that binds C.

Binding using Inline module

There is a binding method using the Inline module. C language runtime execution is possible. Type conversion is manual.

InlineC InlineCPP

Binding using FFI library

There is a binding method using the FFI library. C language runtime execution is possible. You can call the shared library (.so) directly with a call based on the FFI specification. Type conversion is manual.

FFI, FFIRaw , FFIPlatypus

Binding using SPVM

There is a binding method using SPVM. SPVM is a Perl module in the development stage that is being developed by Hiroki Kimoto to solve some of the Perl binding issues and is frequently updated for completion as of September 2021. It's more than 95% complete, but there are some spec issues in the testing phase, some missing features you want to achieve, and inaccurate documentation.

SPVM

I want the performance of numerical calculation and array calculation with Perl.
In such a case, write a function using C language and bind it to Perl. There is a method called.
The C language, which is the foundation and foundation of many software, can work with Perl.
You can also call a library written in C/C++ from Perl.
The Cuda language for computing on the GPU used in deep learning can also be bound.

Basic knowledge of binding

Basic knowledge required for Perl bindings.

Perl programming language

A course in the Perl programming language.

C language

This is a C language course.

Associated Information