This program is an example of a multi-GPU computation (within a single system),
that applies a Saxpy matrix operation decomposed evenly among the GPUs.
SAXPY is a matrix operation which is part of the Basic Linear Algebra Subprograms
(BLAS), which applies the following formula:
Z[i] = α*X[i] + Y[i]; α is a scalar and X/Y same-sized Matrices
Warning: Keep in mind this is an educational example, and as such it does not
handle all extreme cases to try and maintain the code itself readable.
Additionally, the use of overlapping partitions is relatively experimental and might result in unexpected results (segmentation faults within the OpenCL implementation).
Windows is currently untested, but should work correctly with the correct
OpenCL compilation flags.
To compile this example in Linux depends greatly on the configuration.
The following command is used for default paths on the AMD SDK:
g++ -L/opt/AMDAPP/lib/x86_64/ -I/opt/AMDAPP/include main.cpp -lOpenCL -o main
Do keep in mind the paths vary from configuration to configuration, specially
when dealing with NVIDIA GPUs so adapt accordingly.
To compile under OSX it is only required the following command:
g++ -framework OpenCL main.cpp -o main
This program only requires two arguments:
./main numberMatrixElements numberPartitionsPerGPU
And it shall create a mock-up set of matrices with the desired elements to be
executed among all the available GPUs.
The MIT License (MIT)
Copyright © 2014 Fernando Alexandre
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.