Coder Social home page Coder Social logo

mkmf-cu's Introduction

About mkmf-cu

mkmf-cu is a gem to build Ruby extensions written in C/C++ with NVIDIA CUDA. It consists of a simple wrapper command for nvcc and a monkey patch for mkmf.

How to use it.

Instead of require "mkmf", just

require "mkmf-cu"

How does it work?

By requiring "mkmf-cu", compiler commands defined in mkmf will be replaced with mkmf-cu-nvcc, a command included in this gem.

When mkmf-cu-nvcc is called with arguments for gcc or clang, it convert them to ones suitable for nvcc and execute nvcc with them.

For example,

mkmf-cu-nvcc -I. -fno-common -pipe -Os -O2 -Wall -o culib.o -c culib.cu

will execute

nvcc -I. -O2 -o culib.o -c culib.cu --compiler-options -fno-common --compiler-options -Wall

Example

Notice

When the suffix of the name of a file containing CUDA code is not .cu, you must add the option "-x cu" to $CFLAGS or $CXXFLAGS in extconf.rb.

mkmf-cu's People

Contributors

tamuratak avatar

Stargazers

Noel Schankat avatar MingyuanQin avatar Kenta Murata avatar Satoshi Namai avatar  avatar

Watchers

James Cloos avatar Noel Schankat avatar

Forkers

sonots

mkmf-cu's Issues

ruby.h:26:10: error: #include expects "FILENAME" or <FILENAME>

With extconf.rb like:

require 'mkmf-cu'

create_header('extconf.h')
create_makefile('culib/culib')

I get errors as:

compiling ../../../../ext/culib/culib.cu
[given command line options]: --mkmf-cu-ext=c -I. -I/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/x86_64-linux -I/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/backward -I/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0 -I../../../../ext/culib -DRUBY_EXTCONF_H="extconf.h" -I/home/sonots/.rbenv/versions/2.4.1/include -fPIC -I /home/sonots/nccl/build/include -I /home/sonots/.cudnn/active/cuda/include -o culib.o -c ../../../../ext/culib/culib.cu
nvcc -I. -I/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/x86_64-linux -I/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/backward -I/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0 -I../../../../ext/culib -I/home/sonots/.rbenv/versions/2.4.1/include -I/home/sonots/nccl/build/include -I/home/sonots/.cudnn/active/cuda/include -DRUBY_EXTCONF_H="extconf.h" -o culib.o -c ../../../../ext/culib/culib.cu --compiler-options -fPIC --compiler-bindir gcc
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
In file included from /home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby.h:33:0,
                 from ../../../../ext/culib/culib.cu:2:
/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/ruby.h:26:10: error: #include expects "FILENAME" or <FILENAME>
 #include RUBY_EXTCONF_H
          ^
In file included from /home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/ruby.h:36:0,
                 from /home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby.h:33,
                 from ../../../../ext/culib/culib.cu:2:
/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/defines.h:22:10: error: #include expects "FILENAME" or <FILENAME>
 #include RUBY_EXTCONF_H
          ^
In file included from /home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/defines.h:143:0,
                 from /home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/ruby.h:36,
                 from /home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby.h:33,
                 from ../../../../ext/culib/culib.cu:2:
/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/missing.h:28:10: error: #include expects "FILENAME" or <FILENAME>
 #include RUBY_EXTCONF_H
          ^
In file included from /home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/ruby.h:2005:0,
                 from /home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby.h:33,
                 from ../../../../ext/culib/culib.cu:2:
/home/sonots/.rbenv/versions/2.4.1/include/ruby-2.4.0/ruby/intern.h:26:10: error: #include expects "FILENAME" or <FILENAME>
 #include RUBY_EXTCONF_H
          ^

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.