Programming Apple M1 chip GPU - multithreading

I've used CUDA to program an Nvidia GPU but I
want to program my Apple M1 GPU. I can't find
any tools online to do this. CUDA is not for mac.
The Apple M1 GPU should be able to execute
25,000 threads simultaneously. Preferably this
would be a C-like language similar to CUDA.

The standard and portable way of computing on GPU is to use OpenCL.
However, using OpenCL on Apple machines has been deprecated in 2018. Since, Apple recommend developers to use Metal instead (which only works on Apple machines).

Related

What are the programming languages for GPU

I read an article stating that GPU are the future of supercomputing. I would like to know what are the programming languages used for programming on GPU's
OpenCL is the open and cross platform solution and runs on both GPUs and CPUs.
Another is CUDA which is built by NVIDIA for their GPUs.
HLSL,Cg are few others
CUDA has quite a few language ports.. http://en.wikipedia.org/wiki/CUDA

AMD 6 Core and compiling open-source projects

I have been wanting to build my own box with AMD 6 core. I have always used Intel based machines and frankly have not done open-source projects. I want to get into that along with Systems programming but am worried if open-source projects (mainly Linux based) are going to be a problem to compile on AMD?
How difficult is porting (if it is needed) from AMD to Intel and vice-versa. Thanks.
Both AMD and Intel processors use the x86 ISA. You don't generally compile for a specific processor, you compile for the ISA.
Unless you turn on very specific flags (such as -march) while compiling, a binary built on one processor will run on another.
To say it again, there is no problem.
This does not mean the processors are the same. They have different performance characteristics, support different motherboard chipsets, and have different feature sets (for instance, IOMMUs or other advanced virtualization features). But you won't usually be accessing things like the processor-internal performance registers in your everyday life, so don't worry about it and get whichever CPU is right for your desired system configuration and price/performance point.
It's unlikely that it'll be any more complex than compiling anywhere else. I'm pretty sure these kinds of very minor architectural differences are almost a non-issue these days.

How to directly access a GPU?

As most of you know CPUs are not well designed to do floating point calculation in contrast to GPUs. I am wondering how to use GPU's power without any abstraction layer or driver. Can I program for a GPU using assembly, C, C++ language (I mean how?). Although assembly seems to help me access the gpu directly, C/C++ are likely to need a medium library (e.g. OpenCL) to access the GPU.
Let me ask you another question: How much of a modern GPU's capability will be exposed to a programmer without any third-party driver?
The interfaces aren't documented so something like OpenCL is the only practical way to program the GPU directly.
Without a driver you would be stuck trying to reverse engineer the complete functionality of the GPU on your own.
Well, essentially, you would have to write a driver on either Windows or Linux. And the interfaces may be documented depending on which chipset you are trying to use. Intel has loads of PDF documentation on there website. However, this is a non trivial exercise at best and your code would only be able to used on that set of hardware. Meerly reading and understanding the documentation will take a bit of doing in most cases because "OOPs that's not how it really works" and how-tos do this or that aren't documented just the hardware and registers. However if REALLY want to do this your best bet would be to start with open source drivers on Linux for a particular chipset and tweek the to your SICK TWISTED purpose. All in all, other than for the learning aspect, it's prob a BAD idea.
The GPU manufacturer like NVDIA and ATI are closed source companies which has chosen not to disclose the GPU architecture and working abouts to the general public. This is why we cannot directly program the GPU as we can with the most CPU. The only way we can harness the power of the GPU for calculation is by using the provided library like CUDA in case of NVDIA. But there is a possible way where you can directly program a GPU for calculations but for that you need to reverse engineer and document all GPU and its registers and SYSTEMCALLS and you know that is not possible with our access to limited resources and limited time.
PS: The only other way is to sign in as a core developer for the GPU and sign a NDA (Non Disclosure Agreement) with the vendors which is likely not going to happen for starters and individuals like us.

Programming VHDL on Linux?

Anyone knows good environment to program VHDL and simulate it (don't matter Xilinx or Altera) using Linux?
You're stuck with either vendors tools, which are spotty at best on Linux (though my experience with Alteras utilities are somewhat better than with ISE).
However, if all you want to do is run your testbed, not actually synthesize anything, ghdl will be of use.
As mentioned by Arpan (almost) every VHDL simulator is supported by Linux, but they are usually very expensive. Your best shot would be to use one of the following:
Altera DS Web edition (Linux support has just been added) which comes with a free version of ModelSim.
Symphony EDA Sonata 3.1 is available as a free version with limited support.
Xilinx ISE which comes with Xilinxs own simulator: ISim.
Just to add an update to this: Xilinx Vivado has now been released with Linux support for ubuntu/debian and (I believe) redhat/centos.
The software is free for a range of the smaller devices and more common IP cores and includes a mostly decent simulator that is integrated into the tools and is also free.
It has a pretty steep learning curve, as do most of these tools, but as far as software in this industry goes, they've really done a good job with it.
If you prefer open source tools, look into http://www.cliftonlabs.com/vhdl/savant.html - vhdl does not have too many options in the FOSS space currently. If you are opting for vendor tools, all vendors would do Linux version of their simulators. Modelsim is a personal favorite due to the easy-to-debug features that it sports.
For a coding environment, I usually use VIM with vhdl syntax checkers turned on. Sigasi apparently has a commercial IDE with fancy stuff as automatic code completion, on the fly syntax check etc.
Let us know if you have further questions.
Arpan
For coding vhdl, Emacs with vhdl-mode is a must. You can use advanced edition functions, view the structure of designs, manage architectures and configurations. You can setup for multiple simulators.
I use the modelsim from Altera's Quartus web edition. Beware if you use a 64 bits Linux, this version of modelsim is 32 bits only.
There is now QUCS (http://qucs.sourceforge.net/) as well. It is open source and based on FreeHDL.
It can be used to design and simulate circuits using a graphical interface. And it can also simulate VHDL. Although for this you must also design the circuit components on the graphical area.
This video shows it clearly:
https://www.youtube.com/watch?v=-RrQlzLsf18
I'm using the linux ppa on Debian Jessie and it works fine.
GHDL is a nice simulator for VHDL, and even works with some third-party libraries (for example, Xilinx UNISIMS).
If you combine it with gtkwave, you should have a full working VHDL simulator and waveform viewer.
GHDL also supports writing to .GHW waveforms, which are fantastic for small simulations, cause it does include (often) all of the signals on your design.
I've used them with standard RTL simulation, and also for post-synthesis simulation with Xilinx UNISIMs.
Both should be available in your Linux distro repository. If not, you can fetch them from:
GHDL: http://ghdl.free.fr/
GtkWave: http://gtkwave.sourceforge.net/

cuda libraries for search operations

Is there any CUDA library that performs comparison/search operation.
CUDA is an API for creating libraries that run on the NVidia GPU. Consequently, any operations that are to be performed must be custom programmed. There are not a wide range of open-source libraries available.
Programmers use 'C for CUDA' (C with NVIDIA extensions), compiled through a PathScale Open64 C compiler, to code algorithms for execution on the GPU.
http://en.wikipedia.org/wiki/CUDA
You could look at Thrust, which includes a binary_search operation and is very easy to use.

Resources