X hits on this document

76 views

0 shares

0 downloads

0 comments

11 / 26

© NVIDIA Corporation 2009

Saxpy: Hello world

Some things to notice:

Types are implicit

The Copperhead compiler uses a Hindley-Milner type system with typeclasses similar to Haskell

Typeclasses are fully resolved in CUDA via C++ templates

Functional programming:

map, lambda (or equivalent in list comprehensions)

you can pass functions around to other functions

Closure: the variable ‘a’ is free in the lambda function, but bound to the ‘a’ in its enclosing scope

def saxpy(a, x, y):

return map(lambda xi, yi: a*xi + yi, x, y)

Document info
Document views76
Page views76
Page last viewedTue Dec 06 22:16:46 UTC 2016
Pages26
Paragraphs209
Words942

Comments