Code Monkey home page Code Monkey logo

Comments (10)

run4flat avatar run4flat commented on August 28, 2024

Jakub -

Thanks for reporting this, and for figuring out that the verbose output would be helpful! Good bug reports are wonderful.

As you've already figured, this is actually an issue with ExtUtils::nvcc.(Obviously this proves that I need to put better tests in ExtUtils::nvcc.) I don't know if there's any way for me to transfer this bug to that project, but that would be appropriate. If you could reopen this bug in that project, I'd really appreciate it. That having been said, I'll be happy to work on this bug in this issue tracker if you prefer.

My first guess at a workaround would be to try to fiddle with your ccflags. You can try doing something like this for your Build.PL file:

use Module::Build;

use strict;
use warnings;
use ExtUtils::nvcc;

# Create and tweak the config hash
my %build_config = ExtUtils::nvcc::MB;
# Get the ccflags, which we'll tweak and add to %build_config
use Config;
my $ccflags = $Config{ccflags};
$ccflags =~ s/-march=native//;
$build_config{ccflags} = $ccflags;


my $build = Module::Build->new(
    module_name => 'CUDA::Minimal',
    license => 'perl',
    build_requires => {
        'ExtUtils::nvcc' => '0.03',
        # 'ExtUtils::CBuilder' => '0',
    },
    requires => {
        'perl' => '0',
    },
    dist_author => 'David Mertens <[email protected]>',
    config => \%build_config,
    include_dirs => '.',
);

$build->create_build_script;

That simply removes the -march part of ccflags. I think that should do it.

While we're at it, it looks like you have a 64 bit machine. Is this correct? Also, what OS are you running?

David

from perl-cuda-minimal.

jnareb avatar jnareb commented on August 28, 2024

Unfortunately the -march=native comes from different source. With Build.PL modified to look like below:

use Module::Build;

use strict;
use warnings;
use ExtUtils::nvcc;
use Data::Dumper;

# Create and tweak the config hash
my %build_config = ExtUtils::nvcc::MB('verbose');
# Get the ccflags, which we'll tweak and add to %build_config
use Config;
my $ccflags = $Config{ccflags};
$ccflags =~ s/-march=native//;
$build_config{ccflags} = $ccflags;

print Dumper(\%build_config);
print Dumper({ map { $_ => $Config{$_} }
               grep { defined $Config{$_} && $Config{$_} =~ m/native/; }
               keys %Config });

my $build = Module::Build->new(
    module_name => 'CUDA::Minimal',
    license => 'perl',
    build_requires => {
                'ExtUtils::nvcc' => '0.01',
#               'ExtUtils::CBuilder' => '0',
            },
    requires => {
                'perl' => '0',
            },
    dist_author => 'David Mertens <[email protected]>',
    config => \%build_config,
    include_dirs => '.',
);

print "Compiler is ", $build->config('cc'), "\n";
print "Linker is ", $build->config('ld'), "\n";

$build->create_build_script;

I get

$VAR1 = {
          'ccflags' => '-fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
          'cc' => '/usr/bin/perl5.12.3 -MExtUtils::nvcc::Backend -e"ExtUtils::nvcc::Backend::verbose;ExtUtils::nvcc::Backend::compiler" --',
          'ld' => '/usr/bin/perl5.12.3 -MExtUtils::nvcc::Backend -e"ExtUtils::nvcc::Backend::verbose;ExtUtils::nvcc::Backend::linker" --'
        };
$VAR1 = {
          'lddlflags' => '-shared -O2 -pipe -march=native -Wl,-O1 -Wl,--as-needed',
          'config_args' => '-des -Duseshrplib -Darchname=x86_64-linux -Dcc=x86_64-pc-linux-gnu-gcc -Doptimize=-O2 -pipe -march=native -Dldflags=-Wl,-O1 -Wl,--as-needed -Dprefix=/usr -Dsiteprefix=/usr -Dvendorprefix=/usr -Dscriptdir=/usr/bin -Dprivlib=/usr/lib64/perl5/5.12.3 -Darchlib=/usr/lib64/perl5/5.12.3/x86_64-linux -Dsitelib=/usr/lib64/perl5/site_perl/5.12.3 -Dsitearch=/usr/lib64/perl5/site_perl/5.12.3/x86_64-linux -Dvendorlib=/usr/lib64/perl5/vendor_perl/5.12.3 -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.12.3/x86_64-linux -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/share/man/man1 -Dsiteman3dir=/usr/share/man/man3 -Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dlibperl=libperl.so.5.12.3 -Dlocincpth=  -Duselargefiles -Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost -Dperladmin=root@localhost -Dinstallusrbinperl=n -Ud_csh -Uusenm -Di_ndbm -Di_gdbm -Di_db -DDEBUGGING=none -Dinc_version_list=5.12.2/x86_64-linux 5.12.2 5.12.1/x86_64-linux 5.12.1 5.12.0/x86_64-linux 5.12.0  -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64',
          'config_arg5' => '-Doptimize=-O2 -pipe -march=native',
          'optimize' => '-O2 -pipe -march=native'
        };
Making verbose
ExtUtils::nvcc found nvcc args [[-I/usr/lib64/perl5/5.12.3/x86_64-linux/CORE]], [[-c]], [[-D_LARGEFILE_SOURCE]], [[-D_FILE_OFFSET_BITS=64]], [[-O2]], [[-o]], [[compilet-HGMU4.o]]
ExtUtils::nvcc found other args [[-fPIC]], [[-fno-strict-aliasing]], [[-pipe]], [[-pipe]], [[-march=native]]
ExtUtils::nvcc found source files [[compilet-HGMU4.c]]
Running nvcc with args [[-Xcompiler=-fPIC,-fno-strict-aliasing,-pipe,-pipe,-march=native]], [[-I/usr/lib64/perl5/5.12.3/x86_64-linux/CORE]], [[-c]], [[-D_LARGEFILE_SOURCE]], [[-D_FILE_OFFSET_BITS=64]], [[-O2]], [[-o]], [[compilet-HGMU4.o]], [[--x=cu]], [[compilet-HGMU4.c]]
Making verbose
ExtUtils::nvcc found nvcc args [[-shared]], [[-O2]], [[-o]], [[compilet-HGMU4.so]]
ExtUtils::nvcc found other args [[-pipe]], [[-march=native]], [[-Wl,-O1]], [[-Wl,--as-needed]]
ExtUtils::nvcc found source files [[compilet-HGMU4.o]]
Running nvcc with args [[-Xlinker=-pipe,-march=native,-Wl,-O1,-Wl,--as-needed]], [[-shared]], [[-O2]], [[-o]], [[compilet-HGMU4.so]], [[compilet-HGMU4.o]]
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/../../../../x86_64-pc-linux-gnu/bin/ld: unrecognised emulation mode: arch=native
Supported emulations: elf_x86_64 elf_i386 i386linux elf_l1om
collect2: ld returned 1 exit status
nvcc encountered a problem
Warning: ExtUtils::CBuilder not installed or no compiler detected
Proceeding with configuration, but compilation may fail during Build

Compiler is /usr/bin/perl5.12.3 -MExtUtils::nvcc::Backend -e"ExtUtils::nvcc::Backend::verbose;ExtUtils::nvcc::Backend::compiler" --
Linker is /usr/bin/perl5.12.3 -MExtUtils::nvcc::Backend -e"ExtUtils::nvcc::Backend::verbose;ExtUtils::nvcc::Backend::linker" --
Creating new 'MYMETA.yml' with configuration results
Creating new 'Build' script for 'CUDA-Minimal' version '0.01'

This is Linux 2.6.36-gentoo-r4, on AMD Opteron (x86_64), with GeForce GTX 480, and CUDA 4.0.13

from perl-cuda-minimal.

run4flat avatar run4flat commented on August 28, 2024

I'm afraid this may be a much harder problem than I had at first anticipated. Neither Module::Build nor ExtUtils::MakeMaker allow you to tweak all of the compiler settings. (That's one reason why ExtUtils::nvcc attempts to process all the arguments from the command-line invocation.) ExtUtils::MakeMaker might be an easier route for tweaking since you could hack on the Makefile after it's written.

At this point, the easiest route might be to modify ExtUtils::nvcc's argument processing function. It is in ExtUtils/nvcc/Backend.pm, called sub process_args. That function is essentially a series of elsif clauses. (It's a ridiculous hack, but it works for now.) The first elsif is a Fedora 14 hack, and you could put a specific check in there, something like:

        #*#*# Edge case for native architecture flag which gives trouble:
        elsif ($_ eq '-march=native') {
                # Just skip it for now
                next;
        }

Could you try adding that to ExtUtils::nvcc::Backend?

David

from perl-cuda-minimal.

run4flat avatar run4flat commented on August 28, 2024

By the way, what version of gcc are you using? nVidia only supports through gcc v. 4.3, I think. See this post for hints if you run into trouble there: http://forums.nvidia.com/index.php?showtopic=199014

from perl-cuda-minimal.

jnareb avatar jnareb commented on August 28, 2024

Well, I have added exception to sub process_args, then there was ld: unrecognized option '-pipe'. When I added exception for that, then there was ld: unrecognized option '-Wl'... and then I realized that I am looking in wrong place.

What needs to be fixed in ExtUtils::nvcc is the line linker subroutine in ExtUtils::nvcc::Backend module that composes "-Xlinker=<opts>" option. It is:

    # Set up the flags for the compiler arguments:
    unshift @nvcc_args, ("-Xlinker=" . join ',', @other_args)
        if @other_args;

and it should be

    # Set up the flags for the compiler arguments:
    unshift @nvcc_args, ("-Xlinker=" . join ',', map { s/^-Wl,// ? $_ : () } @other_args)
        if @other_args;

I'll try to pass this bugreport to RT for ExtUtils-nvcc ("try to" because I have problems using RT web interface).

from perl-cuda-minimal.

jnareb avatar jnareb commented on August 28, 2024

gcc (Gentoo 4.4.5 p1.2, pie-0.4.5) 4.4.5

from perl-cuda-minimal.

jnareb avatar jnareb commented on August 28, 2024

I'll try to pass this bugreport to RT for ExtUtils-nvcc ("try to" because I have problems using RT web interface).

I used GitHub Issues for perl_nvcc instead. You can find bugreport here: run4flat/perl_nvcc#1

from perl-cuda-minimal.

run4flat avatar run4flat commented on August 28, 2024

Yeah, tracking this bug on Github may be easier than using CPAN's RT. I'm going to mark this as closed. Anybody following along should refer to run4flat/perl_nvcc#1 for further developments.

from perl-cuda-minimal.

run4flat avatar run4flat commented on August 28, 2024

Hmm... does gentoo offer nvcc in ports? nVidia doesn't seem to officially support gentoo: http://developer.nvidia.com/cuda-toolkit-40

from perl-cuda-minimal.

jnareb avatar jnareb commented on August 28, 2024

This is university machine, not mine, and not administered by me... but guessing from location of CUDA in /common/ subdirectory on computation nodes it is installed outside of ports (in a few versions: 3.2, 4.0.11, 4.0.13); nvcc is in /common/cuda-4.0.13/bin/nvcc.

from perl-cuda-minimal.

Related Issues (7)

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.