in reply to Re^3: Inline::CUDA : looking for feedback
in thread Inline::CUDA : looking for feedback

kcott, the immediate cause is that C/C++ compilers are not detected. And possibly errors because of more quoting problems.

it's obvious that I need to handle quoting commands and parameters properly. I will follow anonmonk's suggestion if your \Q \E proves not robust enough.

System C and C++ compiler must be detected properly. For locally-built perl.exe finding the default C-compiler is as easy as $Config{cc} but for C++ is not. For downloaded perl.exe, I have no idea where $Config{cc} will point to! I will also make a basic/preliminary test to check quotes and to check compilers.

Secondly, I have no idea how to affect Makefile.PL vars in windows (for specifying CC,CXX,LD), in the same way I do it in bash:

CC=/usr/local/gcc84/bin/gcc84 CXX=/usr/local/gcc84/bin/g++84 LD=/usr/l +ocal/gcc84/bin/gcc84 perl Makefile.PL

A workaround is, after perl Makefile.PL, to try to modify config/Inline-CUDA.conf

If all else fails I will have to resort to prompting the user during installation. Any opinions on that style?

Thanks for your time spent and valuable feedback. I am not in a hurry, please work on it in your own pace.

bw, bliako

Replies are listed 'Best First'.
Re^5: Inline::CUDA : looking for feedback
by kcott (Archbishop) on Jul 30, 2021 at 10:34 UTC

    There's 15 failed tests ("Failed 15/20 test programs."): I'll need to go through each to find the actual problems.

    If all are simply quoting uses, then the solution is straightforward (if a little tedious to implement across the board). Let's see how that pans out before worrying about config modifications and the like.

    I recall you specified a minimum Perl version of v5.6. I've checked and; quotemeta, \Q and \E are all available in that version, so no issues there.

    "If all else fails I will have to resort to prompting the user during installation. Any opinions on that style?"

    As I said, let's wait and see if secondary options are necessary; however, my general "opinions on that style" are:

    • I don't, as a rule, like it. On a number of occasions, I've started what I expected to be a fairly long-running installation, gone off to do something else while it runs, then returned ten or so minutes later only to find that, two seconds after I walked away from the screen, it prompted: "Specify location of whatever [/usr/bin/whatever]?" or something similar.
    • There are cases where it simply can't be avoided.
    • I have (reluctantly) used it myself in production code.
    • Where it has been necessary, I have tried to indicate early on that user intervention will be required.
    "Thanks for your time spent and valuable feedback. I am not in a hurry, please work on it in your own pace."

    No worries. I am rather eager to see how this works.

    I have, in fact, spent most of this week (at $work) modifying modules and repeatedly going through the make cycle, tweaking tests to reflect the changes. While I'm happy to do this, "All work and no play makes Ken a dull boy.", so I need a break. As I said this morning, I can probably look into this further over the weekend. [Current lockdown restrictions means that I'm not even allowed guests in my home, so I'm certainly free to do this work.]

    — Ken

      I have updated the github repository with a new version which uses ShellQuote::Any to do (some of) the quoting. I have also added a test which tries to run some perl-scripts with space in their name. That's in t/002-spaces-spaces-spaces.t.

      I have also added another repository: which takes over nvidia::ml, fixes its compilation errors and adds 1 more binding. If you install this first, it will be easier to enquire the GPU in current module. It requires nvidia-ml binary library which must be in the toolkit you downloaded. If you can't install that then it's not a problem but 1 test will fail (t/001-enquire-nvidia-gpu.t).

      I suggest you run perl Makefile.PL and if successful, then inspect config/Inline-CUDA.conf to see if cc, cxx, nvcc, ld are all set to valid names (unquoted).

      Following that, run just a few tests: t/000-require-modules.t, t/002-spaces-spaces-spaces.t, t/008-config.t, t/011-basic.t . The last two are compiling CUDA code. If all goes well, then it's likely that all tests will succeed. 031-matrix-multiplication-pass-parameters.t does a matrix multiplication with data passed from the Perl script and results returned back. That's a good base for any CUDA code you may want to write.

      The prompting during installation is only for windows, the user must somehow indicate where a c-compiler is if not in path already.

      BTW, you will be using a newer version of nvcc than mine. So a lot can go wrong there too.

      bw, bliako

        "I suggest you run perl Makefile.PL ..."
        $ perl Makefile.PL PACK001=HASH(0x800172c08) Changes PACK001=HASH(0x800172c08) ignore.txt PACK001=HASH(0x800172c08) lib PACK001=HASH(0x800172c08) nvidia-ml-pl.pdf PACK001=HASH(0x800172c08) nvml.h PACK001=HASH(0x800172c08) nvml_wrap.c PACK001=HASH(0x800172c08) README PACK001=HASH(0x800172c08) PACK001=HASH(0x800172c08) xt PACK001=HASH(0x800172c08) . PACK001=HASH(0x800172c08) nvidia2 PACK001=HASH(0x800172c08) blib/lib/nvidia2/ PACK001=HASH(0x800172c08) blib/lib/nvidia2/ PACK001=HASH(0x800172c08) ml PACK001=HASH(0x800172c08) blib/lib/nvidia2/ml/ PACK001=HASH(0x800172c08) blib/lib/nvidia2/ml/ Warning (mostly harmless): No library found for -lnvidia-ml Generating a Unix-style Makefile Writing Makefile for nvidia2::ml::bindings Writing MYMETA.yml and MYMETA.json
        "... and if successful, then inspect config/Inline-CUDA.conf ..."

        Couldn't find Inline-CUDA.conf even with a case-insensitive search.

        I tried a make anyway:

        $ make cp lib/nvidia2/ blib/lib/nvidia2/ cp lib/nvidia2/ml/ blib/lib/nvidia2/ml/ cp lib/nvidia2/ml/ blib/lib/nvidia2/ml/ cp lib/nvidia2/ blib/lib/nvidia2/ Running Mkbootstrap for bindings () chmod 644 "" "/home/ken/perl5/perlbrew/perls/perl-5.34.0/bin/perl.exe" -MExtUtils:: +Command::MM -e 'cp_nonempty' -- blib/arch/auto/nvidia2/ml +/bindings/ 644 gcc -c -I. -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE -fw +rapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_FORTIFY_S +OURCE=2 -DUSEIMPORTLIB -O3 -DVERSION=\"5.00\" -DXS_VERSION=\"5.00\" + "-I/home/ken/perl5/perlbrew/perls/perl-5.34.0/lib/5.34.0/cygwin-thr +ead-multi/CORE" nvml_wrap.c rm -f blib/arch/auto/nvidia2/ml/bindings/bindings.dll g++ --shared -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,- +-enable-auto-image-base -L/usr/local/lib -fstack-protector-strong nv +ml_wrap.o -o blib/arch/auto/nvidia2/ml/bindings/bindings.dll \ /home/ken/perl5/perlbrew/perls/perl-5.34.0/lib/5.34.0/cygwin-thread- +multi/CORE/cygperl5_34_0.dll -lpthread -ldl \ /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: +nvml_wrap.o:nvml_wrap.c:(.text+0x6af5): undefined reference to `nvmlI +nit' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: +nvml_wrap.o:nvml_wrap.c:(.text+0x6c05): undefined reference to `nvmlS +hutdown' ... several screenfuls of lines like that ... /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: +nvml_wrap.o:nvml_wrap.c:(.text+0x1e977): undefined reference to `nvml +DeviceGetSupportedMemoryClocks' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: +nvml_wrap.o:nvml_wrap.c:(.text+0x1e9ca): undefined reference to `nvml +DeviceGetSupportedGraphicsClocks' collect2: error: ld returned 1 exit status make: *** [Makefile:482: blib/arch/auto/nvidia2/ml/bindings/bindings.d +ll] Error 1

        — Ken