Re: [Haskell-cafe] install cuda

2013-04-01 Thread Peter Caspers
yes, the installation seems to work fine now. However, doing the 
following test in ghci


Prelude :m +Foreign.CUDA
Prelude Foreign.CUDA props 0
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package cuda-0.5.0.0 ... linking ... done.

results in a crash. The CUDA version I am using is 4.1.28. You think 
there is something I could try to analyze this further ?


Thanks a lot for your help
Peter

Am 31.03.2013 21:48, schrieb Geoffrey Mainland:

You need to generate the configure script using autoconf:

https://www.gnu.org/software/autoconf/manual/autoconf.html#autoconf-Invocation

On 03/31/2013 08:27 PM, Peter Caspers wrote:

Hmm, I get

Configuring cuda-0.5.0.0...
setup.exe: configure script not found.

can you help ?

Peter


I was able to install the cuda package under 32-bit GHC 7.4.2 using the
5.0 SDK and use it from within ghci. This required using my fork of the
cuda repo and following the instructions in my WINDOWS.md. Make sure
nvcc is in your path (the CUDA installer should have made this so) and
try 'cabal configure'.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] install cuda

2013-04-01 Thread Peter Caspers

indeed, not very helpful ...

When I installed Cuda the latest driver (296.0) that was running on my 
laptop (a W520 ThinkPad) was not sufficient for version 5.0. However as 
I noticed today in February Lenovo released a driver update (311.0) and 
with that 5.0 is in fact running. :-)


With that the Haskell bindings work well.

Thanks again very much, Geoff
Peter



Am 01.04.2013 12:25, schrieb Geoffrey Mainland:

That is not a very elucidating crash message, so I don't see how to
proceed. After ghci print Loading package cuda-0.5.0.0 ... linking
... done. it just exits? No error dialog, nothing? Did you try building
any of the examples in the cuda package that don't require ghci?

Is your graphics card incompatible with CUDA 5.0, or do you just not
want to update your driver?

Geoff

On 04/01/2013 10:33 AM, Peter Caspers wrote:

yes, the installation seems to work fine now. However, doing the following test 
in ghci

Prelude :m +Foreign.CUDA
Prelude Foreign.CUDA props 0
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package cuda-0.5.0.0 ... linking ... done.

results in a crash. The CUDA version I am using is 4.1.28. You think

there is something I could try to analyze this further ?

Thanks a lot for your help
Peter

Am 31.03.2013 21:48, schrieb Geoffrey Mainland:

You need to generate the configure script using autoconf:



https://www.gnu.org/software/autoconf/manual/autoconf.html#autoconf-Invocation

On 03/31/2013 08:27 PM, Peter Caspers wrote:

Hmm, I get

Configuring cuda-0.5.0.0...
setup.exe: configure script not found.

can you help ?

Peter


I was able to install the cuda package under 32-bit GHC 7.4.2 using the
5.0 SDK and use it from within ghci. This required using my fork of the
cuda repo and following the instructions in my WINDOWS.md. Make sure
nvcc is in your path (the CUDA installer should have made this so) and
try 'cabal configure'.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] install cuda

2013-03-31 Thread Peter Caspers

Hi,

thank you. I could resolve some of the problems by removing spaces from 
the Cuda and Haskell platform installation paths. Now I am left wiht the 
following error:


configure:3596: checking for library containing cuDriverGetVersion
configure:3627: c:\HaskellPlatform\2012.4.0.0\mingw\bin\gcc.exe -o 
conftest.exe -Wl,--hash-size=31 -Wl,--reduce-memory-overheads 
-I/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/include 
-L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib  conftest.c 5
C:\Users\Peter\AppData\Local\Temp\ccOsnsjD.o:conftest.c:(.text+0xc): 
undefined reference to `cuDriverGetVersion'

collect2: ld returned 1 exit status

In fact the library path 
-L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib is not correct 
(there are two subfolders x64 and Win32 containing the lib files) and I 
do not see where this path is actually taken from. I defined an 
enviroment variable LD_LIBRARY_PATH with the correct paths (separated by 
a colon), but it seems to be ignored.


Also copying the lib files to the path I see in the log does not help.

Do you have any hint for me concerning this ?

Peter


Am 31.03.2013 00:56, schrieb Henk-Jan van Tuyl:
On Sat, 30 Mar 2013 20:43:58 +0100, Peter Caspers 
pcaspers1...@gmail.com wrote:



Hi,

I am trying to install the cuda package on a Windows 7 enviroment. 
However I run into an error and can not figure out, what it is.

:
:

configure: error: C compiler cannot create executables
See `config.log' for more details

:

The message says it all:
  See `config.log' for more details
The config.log file is probably in the directory where cabal-install 
unpacks it (%appdata%\cabal\cuda-revision); you can also use the 
commands:

  cabal unpack cuda
  cd cuda
  cabal install
  notepad config.log

I just had the same error message for another package; from the 
config.log file it became clear, that the linker could not find the 
necessary library. Make sure, that the libraries and header files  can 
be found by the compiler and linker, by setting the proper environment 
variables, see [0]


Regards,
Henk-Jan van Tuyl


[0] http://www.haskell.org/haskellwiki/Windows#Tools_for_compilation





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] install cuda

2013-03-31 Thread Peter Caspers


The environment variable should probably be LIBRARY_PATH; I use a 
semicolon as separator.

See also LD_LIBRARY_PATH vs LIBRARY_PATH[0].



yes, it's LIBRARY_PATH. The x64 version of cuda.lib is not recognized at 
all (same error message as if the file was not existent). The Win32 
version works, but results in


configure:3627: c:\HaskellPlatform\2012.4.0.0\mingw\bin\gcc.exe -o 
conftest.exe -Wl,--hash-size=31 -Wl,--reduce-memory-overheads 
-I/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/include 
-L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib  conftest.c 
-lcuda   5
C:\Users\Peter\AppData\Local\Temp\ccOwCQ6n.o:conftest.c:(.text+0xc): 
undefined reference to `cuDriverGetVersion'

collect2: ld returned 1 exit status

I ran nm on cuda.lib and got the entry

nvcuda.dll:
 I .idata$4
 I .idata$5
 I .idata$6
 T .text
 U _IMPORT_DESCRIPTOR_nvcuda
 I _imp__cuDriverGetVersion@4
 T cuDriverGetVersion@4

this looks ok so far. Running nm on the x64 version of the lib file 
results in rubbish output (consistent with the observation above).


I understand that LD_LIBRARY_PATH is used to look up to dll when running 
the program (is that correct?). However we are not at this point yet, 
are we, since the error occurs on the gcc invocation ?



Try my fork:

https://github.com/mainland/cuda

In particular, read WINDOWS.md.


I also read Geoffreys WINDOWS.md and understood that configuring dll 
names are only necessary when using ghci, not for compiled programs 
(nothing to do for this case ?) and in particular not for installing the 
package ?


Actually the dll is not named nvcuda.dll as indicated in the nm output, 
but rather cudart32_41_28.dll I suppose and this file is located in the 
bin subfolder. I should set LD_LIBRARY_PATH to the bin folder, yes ? 
Should I configure this dll name for package installation already (i.e. 
in addition to what is mentioned in WINDOWS.md) ? If yes, how ?


Thank you
Peter


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] install cuda

2013-03-31 Thread Peter Caspers
yes I more or less saw this in the meantime, too. Actually modifying the 
source code on which the error is reported from


configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME Haskell CUDA bindings
| #define PACKAGE_TARNAME cuda
...
| #ifdef __cplusplus
| extern C
| #endif
| char cuDriverGetVersion ();
| int
| main ()
| {
| return cuDriverGetVersion ();
|   ;
|   return 0;
| }

to (for example)

#include stdlib.h
#include stdio.h
#include string.h

#include cuda.h

int
main( int argc, char** argv)
{
int driverVersion = 0;
cuDriverGetVersion(driverVersion);
printf(version = %d\n,driverVersion);
return 0;
}

let me compile, link and run without errors. Alright, got it now, I will 
try your github. Do you think it works with CUDA 4.1 ? On my laptop this 
is the latest version that runs due to the card driver.


Thanks in any case
Peter


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] install cuda

2013-03-31 Thread Peter Caspers

Hmm, I get

Configuring cuda-0.5.0.0...
setup.exe: configure script not found.

can you help ?

Peter


I was able to install the cuda package under 32-bit GHC 7.4.2 using the
5.0 SDK and use it from within ghci. This required using my fork of the
cuda repo and following the instructions in my WINDOWS.md. Make sure
nvcc is in your path (the CUDA installer should have made this so) and
try 'cabal configure'.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] install cuda

2013-03-30 Thread Peter Caspers

Hi,

I am trying to install the cuda package on a Windows 7 enviroment. 
However I run into an error and can not figure out, what it is.


Can someone help ?

Thanks a lot
Peter

C:\Users\Peter\_dev\haskellcabal install cuda
Resolving dependencies...
[1 of 1] Compiling Main ( 
C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1-11856\cuda-0.5.0.1\Setup.hs, 
C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1

-11856\cuda-0.5.0.1\dist\setup\Main.o )
Linking 
C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1-11856\cuda-0.5.0.1\dist\setup\setup.exe 
...

Configuring cuda-0.5.0.1...
cygwin warning:
  MS-DOS style path detected: 
C:\Users\Peter\AppData\Roaming\cabal/share/config.site
  Preferred POSIX equivalent is: 
/cygdrive/c/Users/Peter/AppData/Roaming/cabal/share/config.site
  CYGWIN environment variable option nodosfilewarning turns off this 
warning.

  Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
checking for gcc... C:\Program Files (x86)\Haskell 
Platform\2012.4.0.0\mingw\bin\gcc.exe

checking whether the C compiler works... no
configure: error: in 
`/cygdrive/c/Users/Peter/AppData/Local/Temp/cuda-0.5.0.1-11856/cuda-0.5.0.1':

configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Error: some packages failed to install:
cuda-0.5.0.1 failed during the configure step. The exception was:
ExitFailure 77

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Overloading

2013-03-10 Thread Peter Caspers



In C++ it is perfectly normal to have overloaded functions like

f : Int - Int - Int
f : Int - Char - Int

Something that may not be obvious about Haskell is that
Haskell does NOT have overloaded functions/operators at all.


thanks, this was the core of my question. So by example, if I define a 
Date type as


data Date = Date Int deriving Show

representing a date by its serial number and want two constructors 
(conditions are only examples here)


-- smart constructor with serialNumber
date serialNumber
 | serialNumber  0 = Date serialNumber
 | otherwise = error (invalid serialNumber  ++ show serialNumber)

-- smart constructor with day month year
date2 day month year
| month = 1  month =12 = undefined
| otherwise = error (invalid month  ++ show month)

there is no way of naming both functions date (instead of date2 above, 
which compiles), right ? I still think the basic reason is that


date 5

would then either refer to the first constructor (i.e. representing a 
date with serial number 5) or a partial application of the second
constructor (i.e. representing a function taking month and year and 
returning the date 5th month, year).


If this is the case, what would be the natural Haskell way of organizing 
the smart constructors ? Just number them as above ? Or naming them

dateFromSerialNumber, dateFromDayMonthYear ?

Or would you do it differently from the start ?

Thank you
Peter

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Overloading

2013-03-10 Thread Peter Caspers

Hi Daniel,


Instead of raising an error it's more secure to return a Maybe value.

date :: Int - Maybe Date
date serialNumber
| serialNumber  0 = Just $ Date serialNumber
| otherwise= Nothing


yes, I understand (Maybe seems the equivalent of c++'s boost::optionalT).


-- smart constructor with day month year
date2 day month year
 | month = 1  month =12 = undefined
 | otherwise = error (invalid month  ++ show month)

To increase type safety it's a good idea to use as much explicit data
types instead of Int values as possible:

data Month = January | ...


ok, I will try to change my code in that direction. The idea is clear.


I would use the descriptive names but leave out the 'date', because you could 
still have:

import qualified Date

Date.fromSerialNumber



also clear, yes. I think I have a better starting point now. Not 
impossible that I will come back later with further questions :-)


Thank you for your help
Peter


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Overloading

2013-03-09 Thread Peter Caspers

Hi,

I just started playing around a bit with Haskell, so sorry in advance 
for very basic (and maybe stupid) questions. Coming from the C++ world 
one thing I would like to do is overloading operators. For example I 
want to write (Date 6 6 1973) + (Period 2 Months) for some self defined 
types Date and Period. Another example would be (Period 1 Years) + 
(Period 3 Months).


Just defining the operator (+) does not work because it collides with 
Prelude.+. I assume using fully qualified names would work, but that is 
not what I want.


So maybe make the types instances of typeclasses? This would be Num for 
(+) I guess. For the first example above it will not work however, alone 
for it is not of type a - a - a. Also the second example does not fit, 
because I would have to make Period an instance of Num, which does not 
make sense, because I can not multiply Periods (for example).


Am I missing something or is that what I am trying here just impossible 
by the language design (and then probably for a good reason) ?


A second question concerns the constructors in own datatypes like Date 
above. Is it possible to restrict the construction of objects to 
sensible inputs, i.e. reject something like Date 50 23 2013 ? My 
workaround would be to provide a function say


date :: Int-Int-Int-Date

checking the input and returning a Date object or throw an error if the 
input does not correspond to a real date. I could then hide the Date 
constructor itself (by not exporting it). However this seems not really 
elegant. Also again, taking this way I can not provide several 
constructors taking inputs of different types, can I ?


Thanks a lot
Peter


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Overloading

2013-03-09 Thread Peter Caspers
Thank you all for your answers, this helps a lot. To clarify my last 
point ...



Also again, taking this way I can not provide several constructors taking 
inputs of different types, can I ?

Sorry, didn't get what you mean here.


In C++ it is perfectly normal to have overloaded functions like

f : Int - Int - Int
f : Int - Char - Int

in coexistence, because the compiler can infer (at compile time) what 
function to call by looking at the arguments types.


In Haskell I think this is not possible simply due to the flexibility 
given by partial function application, i.e.


f 5

would not be well defined any more, it could be Int - Int or Char - Int.

Thanks again and kind regards
Peter







___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe