Harlan: a Language That Simplifies GPU Programming 195
hypnosec writes "Harlan – a declarative programming language that simplifies development of applications running on GPU has been released by a researcher at Indiana University. Erik Holk released his work publicly after working on it for two years. Harlan's syntax is based on Scheme – a dialect of LISP programming language. The language aims to help developers make productive and efficient use of GPUs by enabling them to carry out their actual work while it takes care of the routine GPU programming tasks. The language has been designed to support GPU programming and it works much closer to the hardware."
Also worth a mention is Haskell's GPipe interface to programmable GPUs.
dialect of LISP (Score:4, Funny)
Re:dialect of LISP (Score:5, Funny)
Because lisp-style languages are already simplified to the extreme, you mean? Phew, for a moment I thought I spotted a troll.
Re: (Score:2)
Re: (Score:3)
Yes, it does.
Re:dialect of LISP (Score:4, Insightful)
It certainly flattens the syntax learning curve.
The algorithm learning curve on the other hand....
Re: (Score:2)
Then why bother with parentheses? Binary is an even simpler syntax.
Re: (Score:3, Insightful)
Sure, it's academically cooler not to kick your design out of the Garden of Eden, but let's not kid ourselves: besides performance, the other reason Lispy systems haven't conquered is that it's darn hard to have a business model that DOESN'T separate code and data to at least some degree.
This is more an observation than a value judgement about the "rightness" of the situation.
Re: (Score:2)
Each layer can have a separation of code and data. Just at any layer you'll find that your data is code/data from the previous layer and quite frequently your code does little more than feed fixed data to the variable data it is receiving.
Re: (Score:2)
I understand but your point above was that business modeling might require a separation and LISP allows for that. LISP can handle a layer where code and data are distinct.
Re: (Score:2)
Oh I'm sorry I thought you meant business modeling.
I'm not sure that exposing LISP APIs in a library is all that different than anything else.
a) Customer buys the library and pays either a per link fee for distribution or a one time fee
b) Client uses the library more or less however they want (excluding a few limitation in the license)
The business model works the same either way.
Re:dialect of LISP (Score:4, Insightful)
Right, because the only possible way to equate data and code is to wrap it around in an untold number of parentheses. For example if we were to change
(define X (blah blah))
to
define X = blah blah
there is no possible way we could all agree that define returns a list and save the parentheses. /sarcasm
Reality is there is no deep reason to layer scheme with so many parentheses outside the lack of imagination of scheme fanatics.
Re: (Score:2)
LISP has that cool syntax to allow for easiest meta programming.
Arguably Haskell = LISP with better syntax.
so in your case X = blah blah
Re: (Score:2)
Only if you persist in using parentheses everywhere. If you really think about it the supposed symmetry between data and code is not really there, hence the quote. In other words no matter how hard you try to make it look like they are the same either you end up quoting data or you represent functions explicitly via the f( ) convention.
The advantages of the latter are that (1) mimics math notation and (2) keeps the number of parentheses down.
Another question is whether you are able call a function with itself as an argument in your preferred language...
Algol had that already in the 60s without need for endless parenth
Re: (Score:3)
You mean your "deep reason" was to aid a brain addled parser so that it doesn't have to cogitate about what is looking at?
I thought you were aiming higher than that.
Re: (Score:2)
Re: (Score:2)
The most popular RPN was HP's RPL = Reverse Polish LISP.
In any case, yes RPN languages are also quite awesome. And incidentally many GPU programming languages are FORTHs.
Re: (Score:2)
First of all if you have a reason you have to spell it out. This I'm keeping it secret shows that you are not even sure about what you've got.
Second of all what you said makes no sense at all. You can make C extensible "in a first class way" by making every keyword a function or by operator overloading and hence function declarations/overloading extend the language in a "first class way" without any parentheses whatsoever.
Re: (Score:2)
I read your discussion below and he isn't helping.
Assume I have a pre-existing system that already has a good set of primitives and operations that I like.
I can whip up a LISP that uses those primitives and those operators in a few hundred lines of code.
Because LISP structures are so incredibly generic most code will work in my new LISP right out of the box so I can extend my LISP easily and simply.
That's what the parenthesis buy me. No syntax means I get off the ground really cheaply and extend cheaply.
Re: (Score:2)
It is clear you haven't thought about this in any depth if you think it has anything to do with parentheses.
For extensions to be first class what you need is the parser to be ready to treat user constructs the same way as native constructs. This is, for example, what happens with operator overloading in C++. There is nothing stopping you from having keyword overloading too and now extensions are first class.
It is really funny that you think parentheses are fundamental to this. Honestly just by pure syntacti
Re: (Score:2)
There is no other language that can implement the power of Lisp macros.
Which is another way to state my point about the unity of (code . data)
But I think that point is substantially a theoretical one; I write VBA code that generates VBA code all the time. Sure, I may not be able to execute it cleanly in one fell swoop, but you'll notice that MSOffice has orders of magnitude more market penetration than Lisp.
Re: (Score:2)
Yeah, my fundamental problem with LISP is that it's a scripting language, and that used to mean slow (especially before JIT compilers), but GPUs are designed for scripts. Personally I was never a fan of any language that made me count letters, so LISP and Scheme annoyed me with caaaaaaaaar and cddddddddr.
Re: (Score:2)
LISP has had pretty good compilers for several decades. It isn't just a scripting language.
Re: (Score:2)
((easy)is)lisp
Re:dialect of LISP (Score:4, Funny)
((easy)is)lisp
--------------------- ^ Missing parenthesis
Re: (Score:2)
Re: (Score:2)
You likely write code in a syntax that was derived from Lisp every day and don't even realize it.
Re: (Score:2)
So LISP programmers wear skinny jeans and emo glasses?
Link to a simple example (Score:2)
float.kfc [github.com] shows the basic Scheme-style syntax.
I wonder why it uses .kfc as its extension...
Re:Link to a simple example (Score:5, Informative)
Holk reveals [theincredibleholk.org] that the name Harlan comes from a mishearing of fried chicken icon Colonel Sanders' first name, Harland, and this association is also why all the file extensions for Harlan programs are .kfc.
Quebec (Score:2)
Re: (Score:2)
Wait till you hear them try to pronounce Harlan.
Re: (Score:2)
At least the chicken chain is probably less likely to lawyer up than the fiction author.
Re: (Score:3)
Re: (Score:2)
Putting closing parentheses on one line like in the original code is standard convention in most LISP and Scheme languages. The editor takes care of the closing parentheses for you and will give you constant visual feedback on the level you're at and where the opening paren is (e.g. by color coding). Indentation and pretty-printing will also be automatic in any reasonable, modern editor (such as e.g. vim or Emacs).
Re: (Score:2)
The editor takes care of the closing parentheses for you
Perhaps a LISP-specific editor does, but the editor that ships with a computer does not. Even basic features such as automatic copying of leading whitespace from the previous line aren't omnipresent among editors that ship with computers.
Re: (Score:2)
The editor takes care of the closing parentheses for you
Perhaps a LISP-specific editor does, but the editor that ships with a computer does not. Even basic features such as automatic copying of leading whitespace from the previous line aren't omnipresent among editors that ship with windows based computers.
Fixed that for you. Furthermore there are many normal document handling operations where you don't want that operation; it is only programming environments which should auto-handle code type syntax highlighting and auto-completion. We like to call an environment for developing code an IDE.
I agree that many simple text editors don't preserve white space, but even Word preserves indentation level, and notepad++ does quite a bit of syntax highlighting for you.
Also, referring to a sibling of this post "Thi
ECMAScript is the M-expression realized (Score:2)
BTW, there are numerous alternative syntaxes [for Lisp-like languages] around, but none of them was ever successful
Not even JavaScript [stackoverflow.com]?
Re: (Score:2)
Stop using notepad to do your coding and this ceases to be a problem.
Indian University? (Score:3, Informative)
I think you mean Indiana University, mods.
Re: (Score:3, Funny)
I think you mean Indiana University, mods.
No. It's been outsourced.
Indiana, not Indian (Score:5, Insightful)
According to the story it is Indiana University, not Indian University.
I wonder if scheme was in some way necessary or conducive to running on the gpu, or if that was an arbitrary choice. I still have nightmares of car and cdr from way back when.
Re:Indiana, not Indian (Score:5, Interesting)
Scheme/lisp was a bit helpful in the way it has a lot of features simplifying code generation. In fact, lisp is ultimate example of programmers bending towards making things easiest for compilers. It is a lot easier to transform lisp-like code into other representation - you don't really need to write lex/bison-like parser part of the grammar, you can immediately start with transforms.
But it doesn't make it simplier for people using the final language - just for the guy writing the compiler. You have to be masochist to prefer to write
(define (point-add x y)
(match x
((point3 a b c)
(match y
((point3 x y z)
(point3 (+ a x) (+ b y) (+ c z)))))))
instead of something like
define operator+(point3 a, point3 b) = point3(a.x+b.x,a.y+b.y,a.z+b.z)
Lisp makes writing DSLs easy - but resulting DSLs are still Lisp. In the era of things like XText [eclipse.org], which provide full IDE with autocompletion, project management, outlines etc on top of your DSL, there is no real excuse to make things harder then needed
Re: (Score:2, Flamebait)
In the era of things like XText [eclipse.org], which provide full IDE with autocompletion, project management, outlines etc on top of your DSL, there is no real excuse to make things harder then needed
Bullshit. Did you ever try and actually design, write, develop and maintain an industrial-strenght DSL with Xtext ? If yes, then I would be interested to hear from your experience. If not, hear mine: it is hell.
Re: (Score:2)
I always found it deeply ironic that SICP, of all books, starts out with the statement that "Thus, programs must be written for people to read, and only incidentally for machines to execute", and then goes on to use Scheme.
Re: (Score:2)
The thing with lisp syntax is that, at first sight, it looks less intelligible than, say, C++ syntax. But once you get used to the parentheses, it actually is a LOT easier to read and write correctly. All the suggestive syntactic sugars of C/C++/whatever tend to have subtle interference p
Python as pseudocode (Score:2)
As such [Lisp] is readable by programmers and incidentally executed by a machine. In many ways it's almost like writing pseudo code, just in a strange syntax. [...] For a more mainstream language that might fill the same slot I can only think of python.
Yeah, Python is like writing pseudocode too, only without the strange syntax. "Is that the pseudocode?" "No, that's the main function." Yet there are plenty of people on Slashdot who are staunch haters of leading whitespace as block delimiters, despite it being clearer to (human) readers than the parenthesis counting of Lisp.
Re: (Score:3)
The problem with the whitespace is that it makes copy&paste between different block levels extremely troublesome and fragile. It leads to lots of issues that you would never have with a proper block-end statement.
Re: (Score:2)
Lisp programmers don't engage in "parenthesis counting". They read it by indent, like python, and the editor does the counting.
I'm working in both lisp and python at the moment, and it makes me dislike python more every day. Invariably, the allegedly readable, convenient syntax hurts more than it helps.
Re: (Score:2)
Apple's LISP incidentally had the same thing: http://en.wikipedia.org/wiki/Dylan_(programming_language) [wikipedia.org]
Re: (Score:2)
He said Python, not Javascript.
Re: (Score:2)
I dunno, I always liked LISP. There's more typing but it seems logical to me. And the ease of transforming it to something else shouldn't be down played. I've got one API that I have to use frequently that uses LISP like code for sales reports... and often I have to dump that into an excel spreadsheet for some of my sales people... so I wrote a script that did it for me. It's actually really simple. I couldn't imagine doing that with any other language. I just copy the code, run my script, paste into excel
Re: (Score:2)
Please note that lisp stuff above is taken from Harlan - so if you complain about it being ugly, please take it with the guy who came up with Harlan in first place. It _might_ be possible to do better DSL in Lisp, but I was complaining about the route which Harlan has taken.
Re: (Score:2)
Re: (Score:2)
Change in thinking (Score:5, Informative)
Re: (Score:3)
Well, a GPU can optimize computations on arrays but not on structures, so it's better to use structures of arrays... Even is less natural for the programmer.
It is only less natural for you because you've ignored the CPU's SIMD extensions all this time.
My question is if in all this time that you have avoided the CPU SIMD extensions, then why is it at all important that you find the GPU's version of it less natural?
(queue the folks that dont realize that SoA SSE code is a lot faster than AoS SSE code, but will now rabidly defend their suboptimal and thus mostly pointless usage of SSE)
AoS is object oriented (Score:2)
Replace "structure" with "object" and you'll see why most programmers think in terms of arrays of structures and not structures of arrays.
Anyhow, for me that shows an intrinsic limitation of object oriented languages and why C still rules strong. When you run into the limitations of the hardware, you get to a point where object oriented languages are a limiting factor in optimization.
When I started learning how to program neural networks in the 1980s, I realized that by turning object oriented programs insi
Re: (Score:2)
You've never used CLOS then, eh? The optimization you described is a classic use of the metaobject protocol to redefine the representation of instances through a metaclass. You get the performance boost without sacrificing the power of abstraction.
Of course, the SML/Haskell folks would tell you OO is doomed, but only because using a proper type system and algebraic types allows the compiler to do all of the hard stuff for you...
Re: (Score:2)
I just started doing some GPU programming and the change in thinking that it requires even for very simple things can be hard for programmers.
Except for Python/NumPy and Matlab programmers (and perhaps Fortran, idk, never used it).
I was pleasantly surprised when I adapted my Python code (some image processing / neural network stuff) to use OpenCL, and without much effort achieved a 70% reduction in processing time.
Re: (Score:2)
I just started doing some GPU programming and the change in thinking that it requires even for very simple things can be hard for programmers.
Except for Python/NumPy and Matlab programmers (and perhaps Fortran, idk, never used it).
Fortran had parallelizing compilers way, way before this "omg, dual core, we need to rethink everything about programming". I believe it was helped by the language's native matrix/array syntax. This is F90 and later though, earlier standards were horrible, and it's those that give Fortran a bad name even today.
Re: (Score:2)
Writing in Harlan changes your thinking.
It turns you into a total douchebag. One who goes around insisting that everyone else stole and destroyed your ideas.
A marketeer wrote the article (Score:4, Informative)
There are several languages that are written on top of OpenCL - that is the whole idea of this API. But if your read the article, it seems this guy was the actual inventor of the wheel.
Same response happened when some guy made Rootbeer and let some marketeer write an alike article [slashdot.org]. It was suggested that you could just run existing Java-code on the GPU, but that was not true at all - you had to rewrite the code to the rootbeer-API. This Harlan-project is comparable: just beta-software that has not run into the real limits of GPU-computing - but still making big promises that in contrary to their peers they actually will fix the problem.
I'm not saying it can be in the future, but just that this article is a marketing-piece with several promises on future advancements.
Check out Aparapi [google.com] and VexCL [github.com] to name just two. There are loads [khronos.org] and loads [streamcomputing.eu] of these solutions - many of these wrappers slowly advance to higher level languages, and have been in the field a lot longer.
Comtrya! (Score:2)
Re: (Score:2)
Hmm (Score:2, Insightful)
Re: (Score:2, Insightful)
And C is virtually unreadable to anyone brought up with Smalltalk and Ada, so what's your fucking point? It takes something like three days maximum to get used to prefix notation, so learn it if you want to use the tool, and get over with your irrational and insubstantial syntax preferences.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
And how, exactly speaking, would the MagicNewLanguage do that? Because we can probably assume that OpenCL etc. were written by people who knew what they were doing, and are thus already as or nearly ast good as a C-
Practical Example (Score:2)
I had the misfortune to inherit a series of instrument controllers and data collection routines written in Scheme, with hooks into legacy Fortran. A couple of engineers had kept their love of Scheme since university, and 25 years later elected to implement production code in it. Why? Because of the elegance of the grammar, which simplified their job .... because they were steeped in Scheme. When they left the shop, there was no one among the other 50 experienced engineers who had been anywhere near Lisp/Sch
Re: (Score:2)
What a terrible pity. A bunch of engineers got to work on a design they enjoyed and have enthusiasm for their work and also be more productive. Can't possibly understand why a PM would allow that since whoever had to maintain it would have to learn a few new things.
Re: (Score:2)
And C is virtually unreadable to anyone brought up with Smalltalk and Ada, so what's your fucking point? It takes something like three days maximum to get used to prefix notation, so learn it if you want to use the tool, and get over with your irrational and insubstantial syntax preferences.
No one brought up with Smalltalk hasn't been brought up without C. Ada, perhaps, but then again anyone taught Ada was exposed to Fortran and most likely moved to C, which once again predates effing ADA and SMALLTALK. You were far better off with PASCAL as an example.
Re: (Score:2)
I suspect one of the main reasons for using Lisp/Scheme style notation, is that almost all GPU programming anyone would want to do are (based on) mathematical equations.
For mathematicians, a Lisp notation is actually a lot more logical and easier than a C notation. (At least the older ones :)
The whole concept of iterations in calculations is a bit awkward in C (with all the parenthesis, yes...) in comparison to Lisp (where they're fairly well delineated blocks if properly indented)
Yes, you can mostly do the
Re: (Score:2)
Readable Lisp s-expressions (Score:2)
Lisps, like Scheme and Harlan, can be made readable.
Look at the Readable Lisp S-expressions Project [sourceforge.net], which extends traditional Lisp notation and adds capabilities such as infix and traditional f(x) style formatting. We provide open source software (MIT license) implementations, including one that can be used as a preprocessor. So, you can have your Harlan and stuff like infix too.
Without these syntax improvements you're right. Very few developers will be happy writing complicated math expressions wi
It's not the parentheses (Score:2)
People always say it's the parens, but it's not. It's the prefix notation. The first thing that your program does is buried way down in the tree. IMHO, that's why most people find it hard to analyze non-trivial Lisp functions.
(print (eval (read)))
OK, easy. You gotta read, then evaluate, then print the result. In this regard, Lisp is like Forth--not too hard to understand if you write simple, meaningful functions and combine them. I think more Forth programmers are aware of the problem though. Lisp pr
Re: (Score:2)
Is that really any different than any other eager language though? The C equivalent would be print (eval (read (STDIN)));. All you are doing is shifting the location of the parenthesis, and adding more punctuation.
Re: (Score:2)
Hmmmm... In C print isn't standard. printf is printf(char *fmt,...). Your eval function would have to return the result as a string of some kind. You could have it be a pointer to a chunk of memory that holds the string, but then it wouldn't be thread safe (forgetting for a moment that threads aren't spec'd out in C, let's say were POSIX for sake of argument). So if it's thread safe you could return a string, but then how do you free it?
Because of
Come to think of it... (Score:2)
Oh, the danger of spitballing code online. About an hour later I'm watching TV and thinking about my last post. Then I recall that the order of evaluation in C is unspecified.
Thus, even if you did try to write C in prefix style, the order in which things are evaluated is potentially botched. In a pure functional language this doesn't matter. Either that, or Lisp specifies an order of evaluation even if you might have side effects. I think. I'd better shut my mouth before I look any more stupid; but t
Re: (Score:2)
The main things with good functional code is you don't think in terms of "first thing the program does". You shouldn't care about order at all. What's important is the hierarchy. That's why Haskell introduced do notation [wikibooks.org] to allow for imperative statements to be in imperatives if order matters
C is dead. Long live C! (Score:2)
Faster always trumps "easier" in the end. Few languages are programmatically easier than C, it remains to be seen if that is the case here. Often "easier" means "able to do things without an underlying understanding of the architecture", and that's not condusive to Good Eats. (apologies to Alton Brown)
I had a brief foray into Java, but I am amazed at the mileage I've gotten out of the C programming language and it's relatives. (C++, ObjC).
Re: (Score:2)
Context is important.
C is great for small pieces of code. It gets increasingly awkwards as the size increases. So you need to modularize. Which is what Object Oriented languages do. Also what functional languages do, though they do it differently. I don't think either of those is the best choice for a MPU heavy environment. To me that sounds like a dataflow language would be best. But I can't think of any extant that aren't either moribund or so narrowly specialize that they might as well be. (Few l
Re: (Score:2)
So far functional is doing amazing at parallel. Because the languages are side effect free you can embed execution strategies right in the code as a high level modifier that can be easily profiled / changed.
Re: (Score:2)
I agree, they *ought* to be good at parallel. But often they aren't, even if I don't know why. E.g. Racket Scheme has wonderful parallel constructs, but if you read the documentation carefully you discover that those constructs actually only run in one thread. (I'm particularly thinking about "futures" here.) And if I want to start separate isolated processes...I can do that in Ruby or Python or C or ...well, anything that can handle network connections to the same machine.
Usually, I'll admit, the docume
Re: (Score:2)
Python is great. It ain't C.
Simplify != LISP (Score:4, Funny)
LISP? Really?! Were they _trying_ to make the GPU less accessible?
Re: (Score:2)
It was released by an academic researcher. It wouldn't be considered valid for career advancement unless he demonstrated his hardon for Lisp like everyone else in the department.
I have no semaphore... (Score:2)
...and I must scream.
Another programming language waste of time (Score:2)
Re: (Score:2)
Is the haskell compiler actually generating the shader code?
Re: (Score:2)
I think it can, but seems it is so complicated and unreadable that sample project at https://github.com/csabahruska/GFXDemo [github.com] is using gsl for shaders...
Re: (Score:2)
Why is it that every single story about something new, whether justified or not, is always met with a torrent of naysayers?
because the article is filled with references to "snob" languages? can I use this language easily from with c++? java? .net? in android?
Re: (Score:2)
Because /. has become incredibly conservative.
Re: (Score:2)
American Mac keyboards have {} [] printed on them.
It is only european (all or only german?) that don't have.
Also keep in mind, Lisp was invented long before Macs.
Re: (Score:2)
it's probably all european, since scandinavian keyboards miss the prints. funny thing is that it doesn't help at all that they're missing them, they just thought it would look cooler if they weren't printed on them..
or is it all modern mac keyboards? I seem to recall that the older pre-steve-batshit-crazied macs had them?
Re: (Score:2)
That has nothing to do with Mac or not Mac, it is a keyboard layout problem. Yes, PC keyboards access them via ALT-GR and show the keys ...
Non programmers don't need [] {} at all, so non programmers don't miss them.
OTOH americans have not the special chars we put on the [] {} places, like german Umlauts (sorry can not show them here as /. will eat them).
Re: (Score:2)
Re: BS (Score:2)
Re:MOV ES:[BP],#255,ecx,xyz !! (Score:4, Funny)
"MOV ES:[BP],#255,ecx,xyz
Is not simple enough ??"
That's only the old use of those cards, nowadays kids need functions like MakeBitCoins(500) or SETIFindET() and so on.
Hate (Score:2)
Hate. Let me tell you how much I've come to hate this language since I began to code in it. There are 387.44 million parentheses ensconced around pages and pages of convoluted s-expressions that fill my programs. If the word 'hate' was engraved between each pixel of each character of those thousands of lines it would not equal one one-billionth of the hate I feel for functional programming at this micro-instant. For you. Hate. Hate.