Compilation error on Windows in zlaqps3_gpu.cu

Open discussion for MAGMA

Compilation error on Windows in zlaqps3_gpu.cu

Postby Matt Phillips » Thu Sep 19, 2013 8:37 pm

I've learned to expect Windows builds to be a nightmare, but this surprises me, as it's unclear how it could arise from a faulty environment:

[..compiling fine...]
nvcc -O3 -DADD_ --compiler-options -DWIN64 -DWINDOWS -DWIN -DGPUSHMEM=200 -DHAVE_CUBLAS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=compute_20 -I"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.5"/include -I../include -I../control -c zlacpy_batched.cu -o zlacpy_batched.cu_o
nvcc -O3 -DADD_ --compiler-options -DWIN64 -DWINDOWS -DWIN -DGPUSHMEM=200 -DHAVE_CUBLAS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=compute_20 -I"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.5"/include -I../include -I../control -c zlaqps2_gpu.cu -o zlaqps2_gpu.cu_o
nvcc -O3 -DADD_ --compiler-options -fno-strict-aliasing -DUNIX -DGPUSHMEM=200 -DHAVE_CUBLAS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=compute_20 -I"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.5"/include -I../include -I../control -c zlaqps3_gpu.cu -o zlaqps3_gpu.cu_o
zlaqps3_gpu.cu(144): error: calling a __host__ function("_copysign") from a __global__ function("magma_zscale_kernel") is not allowed

1 error detected in the compilation of "C:/cygwin64/tmp/tmpxft_00002104_00000000-8_zlaqps3_gpu.cpp1.ii".
cl : Command line warning D9002 : ignoring unknown option '-fno-strict-aliasing'
zlaqps3_gpu.cu
../Makefile.internal:92: recipe for target `zlaqps3_gpu.cu_o' failed
make[1]: *** [zlaqps3_gpu.cu_o] Error 2
[etc.]


I'm compiling in Cygwin with gcc 4.8.1 on Windows 8, with OpenBLAS, using CUDA 5.5 on a 650m. I've compiled with OpenBLAS successfully on Ubuntu 12.04 (on a different machine). As you can see, other functions compile successfully before it breaks here, such as zlaqps2_gpu.cu immediately before it. Anybody see anything wrong with my make.inc file?

GPU_TARGET = Fermi

CC = gcc
NVCC = nvcc
FORT = gfortran

ARCH = ar
ARCHFLAGS = cr
RANLIB = ranlib

OPTS = -O3 -DADD_
F77OPTS = -O3 -DADD_
FOPTS = -O3 -DADD_ -x f95-cpp-input
NVOPTS = -O3 -DADD_ --compiler-options -fno-strict-aliasing -DWIN64
LDOPTS = -fPIC -Xlinker -zmuldefs

LIB = -lopenblas -lpthread -lcublas -lcudart -lm

CUDADIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.5"

LIBDIR = -LC:/Users/matt/Libraries/openblas/openblas-0.2.8 \
-L$(CUDADIR)/lib/x64

INC = -I$(CUDADIR)/include
Matt Phillips
 
Posts: 8
Joined: Sat Feb 23, 2013 11:01 am

Re: Compilation error on Windows in zlaqps3_gpu.cu

Postby Matt Phillips » Thu Sep 19, 2013 9:42 pm

Lol so I went into zlaqps3_gpu.cu and all other files which use copysign and replaced

x = copysign(x, y);


with

Code: Select all
if (x<0 && y>0 || x>0 && y<0) x = -x;


and things are compiling fine again. I'm wondering if copysign was a macro for something like the above (using the ternary operator) in Windows 7 but has been replaced with a proper function call in Windows 8. I'm not the furst to build under Windows so I can't imagine anything else.
Matt Phillips
 
Posts: 8
Joined: Sat Feb 23, 2013 11:01 am

Re: Compilation error on Windows in zlaqps3_gpu.cu

Postby mgates3 » Mon Sep 23, 2013 1:11 pm

We just noticed this issue. In control/common_magma.h, add #ifdef _MSC_VER ... #endif as shown below.

Code: Select all
    // functions where Microsoft fails to provide C99 standard
    // (only with Microsoft, not with e.g. nvcc on Windows)
    #ifdef _MSC_VER
    #define copysign(x,y) _copysign(x,y)
    double log2( double x );  // defined in auxiliary.cpp
    #endif


Basically, copysign is a standard C99 function, which nvcc supports. Sadly, Microsoft has chosen a different name, _copysign, instead of complying with the standard. (Admittedly, they don't claim to support C99.)
-mark
mgates3
 
Posts: 336
Joined: Fri Jan 06, 2012 2:13 pm

Re: Compilation error on Windows in zlaqps3_gpu.cu

Postby Matt Phillips » Sat Oct 05, 2013 6:22 pm

Great, thank you.

Matt
Matt Phillips
 
Posts: 8
Joined: Sat Feb 23, 2013 11:01 am


Return to User discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests