Completely general purpose code on a GPU [closed] - c

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I was approached by a client to work on a project that will involve trying to run full scale programs on the GPU with OpenCL.
I have decent knowledge of CUDA and low level machine architecture. As far as I understand, GPU code does not have a call stack, nor does it have pointers, or any unstructured control flow mechanism like goto, exceptions or function pointers.
To me it resembles a rudimentary FORTRAN dialect in terms of semantics.
I know that GPU kernels called from another GPU kernel get inlined like macro expansions, there is no CALL/RET mechanism
As far as I understand, you cannot have a lexically scoped language without a stack and the dialect that OpenCL compiles is a very flat subset of C and similarly CUDA, while allowing templates and stuff, gives us only a very small subset of C++
The client wants to translate from Javascript to C to LLVM and then to OpenCL bytecode, or somehow get full scale programs to run on the GPU, even if they run slowly with no parallelism
Am I right in convincing the client that what he hopes to achieve is technically impossible and not really useful?

Related

Port existing C code to ARMv7 [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I was recently given the source code for an audio decoder which executes fine with on Windows when compiled with MSVC.
I was assigned the job of porting this decoder (which is written in c) to the ARMv7 platform.
Since I'm totally new to this field, I'm not sure how to go about doing this. I have already googled a lot, but could not find much that applied to my particular case.
Any suggestions about how to pull off such a port would be greatly appreciated.
Compile it and see what breaks is a good place to start.
ARM is a 32 bit target and off-the-shelf ARM based micro-controllers are invariably little-endian like x86, so there are generally few issues porting code.
If the code makes OS calls to Win32, or uses third-party libraries not ported to ARM, then of course you will need to remove those dependencies or port to the target environment. Similarly if the code makes use of the PC based hardware, such as the sound card, that will certainly need to be adapted.
Code and algorithms that simply processes data should port directly if the code quality was sufficiently portable in the first instance. Undefined or implementation defined compiler behaviour however will need to have been be avoided, since this is likley to differ between compilers and targets.

Integrate C library with Java, Ruby, Node, Python, Go, .NET [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Status Quo
For a project of mine I need a client library that communicates with my API for every major programming platform. Currently I implemented just one (Java) and was thinking 'I don't want to do this 8 times (or hope someone else will)'.
The client is relatively small, but not trivial; does mostly JSON reading/writing and sending TCP/UDP data over SSL. Every call to the client is fire-and-forget, so it works completely asynchronously in its own thread.
Problem
I was asking myself if it made sense to write a single C library and integrate it with the other platforms.
I did a bit of research and it seems every platform deals with this differently (obviously) with varying necessary efforts. I also realised that I never saw something like it - for example database drivers always seem to be written from scratch rather than using a C library at the core. Is the overhead too big?
I also read about Thrift, Protocol Buffers etc. - but this seems to be aimed at network interoperability?
Question
So the final question is:
Is it feasible to use a single C library at the core of each platform's client? If yes: how should it be done?
Using a C library makes sense if you want to consolidate all implementations of the same functionality into one piece of code - it is probably the only language that can be universally used by higher level languages.
Your work would be significantly easier if you could automate the process to a degree. You might want to have a look at SWIG. It is a binding generator that allows C/C++ code to be used with a large number of other programming languages, including most, if not all, of the languages that you mentioned.
For my rather superficial experience with it, SWIG does a rather decent job, although the generated code does occasionally need some tweaking...

Carry Around C Compiler [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm aware that there are programable calculators but are there any calculator sized (prehaps bigger) devices that could compile C code?
Almost anything that has a decent sized processor (32-bit) and an operating system that gcc supports can be made to compile C/C++ etc listed here. The tricky parts are:
You need enough storage to have sufficient libraries etc to make it worthwhile. (RAM may also be an issue in some cases, especially if you try to compile LARGE sections of code).
Getting the code onto the device - if you are just copying files over, then it's no big deal, but if you need to actually type code in, you will need a keyboard and a screen.
I personally prefer to use a device to log into my desktop over the internet. As long as you can convince the machine to run ssh or putty (which should work on a lot of things - I can do it on my feeble Android phone - there are versions of Windows phone, iphone and Nokia/Symbian phones can do it too). Now you can compile code on your desktop machine from wherver you are...
Haven't you heard of the Raspberry Pi?

If I'm making a new programming language, should I compile to assembly or C? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm making a language that is based on a different mathematical model than is normally used. If I use C, well, I'm not sure that I can because the model is so different compared to C. But then if I use assembly code, it's not portable, is it? Is there a generic assembly language that can be abstracted over all of the architectures possibly that I'm not aware about? Or am I missing something? I suppose that if C is Turing complete, then I should be able to compile to it if my language is Turing complete... Is assembly more powerful than C? If I wanted a compiled language, what are the advantages of compiling to assembly, and what are the advantages of compiling to C?
I would say C. It will save you tons of time writing compilers for every platform when you can write one and let the C compiler do the dirty work for you. C has been used as intermediate language for a lot of higher-level languages with design different from C, such as C++.
Also, there are no assembly language that is cross platform without massive modification.

What free JIT compilers are there today, and which is easier to use? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I will start writing a JIT/interpreter for a small language, and would like to use some of the free JIT tools/libraries available today. What are my options (I only know of libjit, LLVM and GNU lightning), and which would be the easier to use (but not too slow)?
The requiremens would be:
Compiling time is not important
Execution time is important, but so long as using the JIT compiler isn't too hard
Ease of use is important
No garbage collection necessary.
Actually, no run-time environment necessary (I'd really just want the JIT: compile into a memory region, then take the pointer and start executing the generated code)
Development will be done in plain standard C (no C++, no platform-specific features), with pthreads.
Plain standard C with good execution time? you must be looking for LuaJIT(actually dynasm which is the backend, but thats still part of LuaJIT), which is a tracing JIT compiler (where as most of those mentioned are static). It does have garbage collection, but it can easy be taken out or modified (there is a planned overhaul of it soonish), and it has a native FFI, so it can easily do external binding (from a C level, so you don't always have to get into the nitty gritty).
Best part, its totally public domain code, and the code is the documentation (which is nice as its well structured).

Resources