makefile question when adding a file to magmablas/ directory

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
NASA_SimDeveloper
Posts: 8
Joined: Wed Apr 17, 2019 11:50 am

makefile question when adding a file to magmablas/ directory

Post by NASA_SimDeveloper » Wed May 22, 2019 10:38 am

I created a new file that I want compiled into the magmablas library. I tried adding my filename to Makefile.gen but then I noticed it said "AutoGenerated" . I also added it to CMake.src but my new file would make. I tried >> make cleanall but my file would never try to compile.

I also tried creating a build/ directory and running >> ccmake ..
but that did not seem to work.

Is there a proper way to add a *.cu file to the magmablas/ library?

abdelfattah83
Posts: 8
Joined: Mon Dec 10, 2018 3:02 pm

Re: makefile question when adding a file to magmablas/ directory

Post by abdelfattah83 » Thu May 23, 2019 11:11 pm

You should add your new CUDA file to the Makefile.src file under the magmablas subdirectory.

Ahmad

NASA_SimDeveloper
Posts: 8
Joined: Wed Apr 17, 2019 11:50 am

Re: makefile question when adding a file to magmablas/ directory

Post by NASA_SimDeveloper » Tue May 28, 2019 8:32 am

I have my new file in Makefile.src but it never tries to compile. I think it needs to be configured somehow to know that it needs compiled. I placed my new file after dznrm2.cu in the Make.src:
$(cdir)/dznrm2.cu \
$(cdir)/dstddev_mean.cu \

Do I need to configure?




I tried the cmake approach but I get an error. I am using Redhat 7.5.
...
...
...
-- Configuring done
CMake Error at /usr/share/cmake/Modules/FindCUDA.cmake:1441 (add_library):
Cannot find source file:

control/magma_sauxiliary.cpp

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
Call Stack (most recent call first):
CMakeLists.txt:402 (cuda_add_library)


-- Build files have been written to: /opt/magma-2.5.0/build

NASA_SimDeveloper
Posts: 8
Joined: Wed Apr 17, 2019 11:50 am

Re: makefile question when adding a file to magmablas/ directory

Post by NASA_SimDeveloper » Tue May 28, 2019 10:44 am

It is interesting that dznrm2.cu is only included in the Makefile.src once but dnrm2.o, dznrm2.o, scnrm2.o and snnrm.o are in the magmablas/ directory. Am I required to have 4 variations of dstddev_mean.cu in magmablas/ directory?

I tried cleanall and clean but I never get my magmablas/dstddev_mean.cu to compile.

mgates3
Posts: 893
Joined: Fri Jan 06, 2012 2:13 pm

Re: makefile question when adding a file to magmablas/ directory

Post by mgates3 » Tue Jun 04, 2019 9:45 am

Currently, CMake won't see new files. They have to be added with `make` first, which will generate magma/CMake.src.

MAGMA uses a precision generator (magma/tools/codegen.py) to generate all 4 precisions (s, d, c, z for single, double, complex-single, complex-double) from, usually, the complex-double code. So only the complex-double version is in the Makefile.src; the others will be generated and will automatically show up in magma/Makefile.gen.

What does the header in your file look like? If you wrote complex-double (z) and want the others (s, d, c) to be generated, then it should have something like:
@precisions norm z -> s d c
It should NOT have:
@generated from ...
If it has an @generated line, the file will get ignored. If you don't need precision generation, then just omit both those lines (@precisions and @generated).

All that said, I don't really recommend adding files to MAGMA, since you will have to redo it for every new version. I recommend adding files to your application.

-mark

mgates3
Posts: 893
Joined: Fri Jan 06, 2012 2:13 pm

Re: makefile question when adding a file to magmablas/ directory

Post by mgates3 » Tue Jun 04, 2019 9:48 am

Also, you can compile using `make magmablas/dstddev_mean.o` (from the top magma directory) to compile a single file to see if it is working, without recompiling the entire library. E.g.,

Code: Select all

mint ~/Documents/magma> make magmablas/dznrm2.o
nvcc -m64 -O3         -DNDEBUG -DADD_       -Xcompiler "-fPIC -Wall -Wno-unused-function" -std=c++11  -gencode arch=compute_30,code=sm_30 -gencode arch=compute_30,code=compute_30 -I/usr/local/cuda-9.0/include -I/Users/mgates/Documents/pp/libtest -I./include -I./control -c -o magmablas/dznrm2.o magmablas/dznrm2.cu
Then use `make` or `make lib` to compile the rest of the MAGMA library.

-mark

mgates3
Posts: 893
Joined: Fri Jan 06, 2012 2:13 pm

Re: makefile question when adding a file to magmablas/ directory

Post by mgates3 » Tue Jun 04, 2019 9:53 am

As for setting up a new source file for use in CMake, you need to run `make generate` or `make CMake.src`.

I'm not sure why CMake wouldn't find `control/magma_sauxiliary.cpp`. What version of MAGMA are you using? Or did you get MAGMA directly from the bitbucket repo? Possibly the `make generate` would solve that problem, too.

-mark

Post Reply