Move add.adb and enum_devices.adb into new examples directory.
CUDA_ADA = libcudaada-$(VERSION)
TARBALL = $(CUDA_ADA).tar.bz2
-all: build_release
+all: build_examples
-build_release:
- @LIBRARY_PATH=$(LIBRARY_PATH) gnatmake -p -Pcuda -XARCH=$(ARCH)
+build_examples:
+ @LIBRARY_PATH=$(LIBRARY_PATH) gnatmake -p -Pcuda_examples -XARCH=$(ARCH)
build_tests:
@LIBRARY_PATH=$(LIBRARY_PATH) gnatmake $(GMAKE_OPTS) -Pcuda_tests.gpr \
@echo "Creating release tarball $(TARBALL) ... "
@git archive --format=tar HEAD --prefix $(CUDA_ADA)/ | bzip2 > $(TARBALL)
-.PHONY: all build_tests build_release clean dist doc perf tests
+.PHONY: all build_tests build_examples clean dist doc perf tests
+++ /dev/null
---
--- Copyright (C) 2011, 2012 Reto Buerki <reet@codelabs.ch>
--- Copyright (C) 2011, 2012 Adrian-Ken Rueegsegger <ken@codelabs.ch>
--- University of Applied Sciences Rapperswil
---
--- This program is free software: you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation, either version 3 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with this program. If not, see <http://www.gnu.org/licenses/>.
---
-
-with "cuda_common";
-
-project Cuda is
-
- for Object_Dir use "obj";
- for Main use ("add.adb", "enum_devices.adb");
- for Source_Dirs use ("src");
-
- Compiler_Switches := Cuda_Common.Compiler_Switches & "-gnatwale";
-
- package Compiler is
- for Default_Switches ("ada") use Compiler_Switches;
- end Compiler;
-
- package Linker is
- for Default_Switches ("ada") use Cuda_Common.Linker_Switches;
- end Linker;
-
- package Binder is
- for Default_Switches ("ada") use Cuda_Common.Binder_Switches;
- end Binder;
-
-end Cuda;
--- /dev/null
+--
+-- Copyright (C) 2011, 2012 Reto Buerki <reet@codelabs.ch>
+-- Copyright (C) 2011, 2012 Adrian-Ken Rueegsegger <ken@codelabs.ch>
+-- University of Applied Sciences Rapperswil
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+--
+
+with "cuda_common";
+
+project Cuda_Examples is
+
+ for Object_Dir use "obj/examples";
+ for Main use ("add.adb", "enum_devices.adb");
+ for Source_Dirs use ("src", "examples");
+
+ Compiler_Switches := Cuda_Common.Compiler_Switches & "-gnatwale";
+
+ package Compiler is
+ for Default_Switches ("ada") use Compiler_Switches;
+ end Compiler;
+
+ package Linker is
+ for Default_Switches ("ada") use Cuda_Common.Linker_Switches;
+ end Linker;
+
+ package Binder is
+ for Default_Switches ("ada") use Cuda_Common.Binder_Switches;
+ end Binder;
+
+end Cuda_Examples;
--- /dev/null
+--
+-- Copyright (C) 2011 Reto Buerki <reet@codelabs.ch>
+-- Copyright (C) 2011 Adrian-Ken Rueegsegger <ken@codelabs.ch>
+-- University of Applied Sciences Rapperswil
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+--
+
+with Ada.Text_IO;
+with Ada.Numerics.Real_Arrays;
+
+with CUDA.Autoinit;
+with CUDA.Compiler;
+
+pragma Unreferenced (CUDA.Autoinit);
+
+procedure Add
+is
+ use CUDA;
+
+ package Real_Vector_Args is new Compiler.Arg_Creators
+ (Data_Type => Ada.Numerics.Real_Arrays.Real_Vector);
+ use Real_Vector_Args;
+
+ N : constant := 32 * 1024;
+
+ A : Ada.Numerics.Real_Arrays.Real_Vector := (1 .. N => 2.0);
+ B : Ada.Numerics.Real_Arrays.Real_Vector := (1 .. N => 2.0);
+ C : aliased Ada.Numerics.Real_Arrays.Real_Vector := (1 .. N => 0.0);
+ Src : Compiler.Source_Module_Type;
+ Func : Compiler.Function_Type;
+ Module : Compiler.Module_Type;
+begin
+ Src := Compiler.Create
+ (Preamble => "#define N" & N'Img,
+ Operation => "__global__ void add( float *a, float *b, float *c ) {" &
+ " int tid = blockIdx.x;" &
+ " while (tid < N) {" &
+ " c[tid] = a[tid] + b[tid];" &
+ " tid += gridDim.x;" &
+ "}}");
+
+ Module := Compiler.Compile (Source => Src);
+ Func := Compiler.Get_Function (Module => Module,
+ Name => "add");
+
+ Func.Call
+ (Args =>
+ (1 => In_Arg (Data => A),
+ 2 => In_Arg (Data => B),
+ 3 => Out_Arg (Data => C'Access)));
+
+ for I in C'Range loop
+ if C (I) /= A (I) + B (I) then
+ raise Program_Error with "Results mismatch";
+ end if;
+ end loop;
+
+ Ada.Text_IO.Put_Line ("Calculation successful");
+end Add;
--- /dev/null
+--
+-- Copyright (C) 2011 Reto Buerki <reet@codelabs.ch>
+-- Copyright (C) 2011 Adrian-Ken Rueegsegger <ken@codelabs.ch>
+-- University of Applied Sciences Rapperswil
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+--
+
+with Ada.Text_IO;
+
+with CUDA.Driver;
+
+procedure Enum_Devices
+is
+ use CUDA.Driver;
+
+ procedure Print_Device (Dev : Device_Type);
+ -- Print properties of given CUDA device to stdout.
+
+ procedure Print_Device (Dev : Device_Type)
+ is
+ use Ada.Text_IO;
+
+ MTD : constant Nat_3_Array := Max_Thread_Dimensions (Dev);
+ MGS : constant Nat_3_Array := Max_Grid_Size (Dev);
+ begin
+ New_Line;
+ Put_Line ("Name : " & Name (Dev));
+ Put_Line ("Compute capability :" & Compute_Capability
+ (Dev)'Img (1 .. 4));
+ Put_Line ("Clock rate :" & Clock_Rate (Dev)'Img);
+ Put_Line ("Device copy overlap : " & Copy_Overlap (Dev)'Img);
+ Put_Line ("Kernel exec timeout : " & Kernel_Exec_Timeout (Dev)'Img);
+ Put_Line ("Total global mem :" & Total_Global_Mem (Dev)'Img);
+ Put_Line ("Total constant mem :" & Total_Constant_Mem (Dev)'Img);
+ Put_Line ("Max mem pitch :" & Max_Mem_Pitch (Dev)'Img);
+ Put_Line ("Texture alignment :" & Texture_Alignment (Dev)'Img);
+ Put_Line ("Multiprocessor count :" & Multiprocessor_Count (Dev)'Img);
+ Put_Line ("Shared mem per mp :" & Shared_Mem_Per_Block (Dev)'Img);
+ Put_Line ("Registers per mp :" & Regs_Per_Block (Dev)'Img);
+ Put_Line ("Threads in warp :" & Warp_Size (Dev)'Img);
+ Put_Line ("Max threads per block :" & Max_Threads_Per_Block (Dev)'Img);
+ Put_Line ("Max thread dimensions : ("
+ & MTD (1)'Img & "," & MTD (2)'Img & "," & MTD (3)'Img & " )");
+ Put_Line ("Max grid size : ("
+ & MGS (1)'Img & "," & MGS (2)'Img & "," & MGS (3)'Img & " )");
+ end Print_Device;
+begin
+ Ada.Text_IO.Put_Line ("Found" & Device_Count'Img & " CUDA device(s):");
+ Iterate (Process => Print_Device'Access);
+end Enum_Devices;
+++ /dev/null
---
--- Copyright (C) 2011 Reto Buerki <reet@codelabs.ch>
--- Copyright (C) 2011 Adrian-Ken Rueegsegger <ken@codelabs.ch>
--- University of Applied Sciences Rapperswil
---
--- This program is free software: you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation, either version 3 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with this program. If not, see <http://www.gnu.org/licenses/>.
---
-
-with Ada.Text_IO;
-with Ada.Numerics.Real_Arrays;
-
-with CUDA.Autoinit;
-with CUDA.Compiler;
-
-pragma Unreferenced (CUDA.Autoinit);
-
-procedure Add
-is
- use CUDA;
-
- package Real_Vector_Args is new Compiler.Arg_Creators
- (Data_Type => Ada.Numerics.Real_Arrays.Real_Vector);
- use Real_Vector_Args;
-
- N : constant := 32 * 1024;
-
- A : Ada.Numerics.Real_Arrays.Real_Vector := (1 .. N => 2.0);
- B : Ada.Numerics.Real_Arrays.Real_Vector := (1 .. N => 2.0);
- C : aliased Ada.Numerics.Real_Arrays.Real_Vector := (1 .. N => 0.0);
- Src : Compiler.Source_Module_Type;
- Func : Compiler.Function_Type;
- Module : Compiler.Module_Type;
-begin
- Src := Compiler.Create
- (Preamble => "#define N" & N'Img,
- Operation => "__global__ void add( float *a, float *b, float *c ) {" &
- " int tid = blockIdx.x;" &
- " while (tid < N) {" &
- " c[tid] = a[tid] + b[tid];" &
- " tid += gridDim.x;" &
- "}}");
-
- Module := Compiler.Compile (Source => Src);
- Func := Compiler.Get_Function (Module => Module,
- Name => "add");
-
- Func.Call
- (Args =>
- (1 => In_Arg (Data => A),
- 2 => In_Arg (Data => B),
- 3 => Out_Arg (Data => C'Access)));
-
- for I in C'Range loop
- if C (I) /= A (I) + B (I) then
- raise Program_Error with "Results mismatch";
- end if;
- end loop;
-
- Ada.Text_IO.Put_Line ("Calculation successful");
-end Add;
+++ /dev/null
---
--- Copyright (C) 2011 Reto Buerki <reet@codelabs.ch>
--- Copyright (C) 2011 Adrian-Ken Rueegsegger <ken@codelabs.ch>
--- University of Applied Sciences Rapperswil
---
--- This program is free software: you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation, either version 3 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with this program. If not, see <http://www.gnu.org/licenses/>.
---
-
-with Ada.Text_IO;
-
-with CUDA.Driver;
-
-procedure Enum_Devices
-is
- use CUDA.Driver;
-
- procedure Print_Device (Dev : Device_Type);
- -- Print properties of given CUDA device to stdout.
-
- procedure Print_Device (Dev : Device_Type)
- is
- use Ada.Text_IO;
-
- MTD : constant Nat_3_Array := Max_Thread_Dimensions (Dev);
- MGS : constant Nat_3_Array := Max_Grid_Size (Dev);
- begin
- New_Line;
- Put_Line ("Name : " & Name (Dev));
- Put_Line ("Compute capability :" & Compute_Capability
- (Dev)'Img (1 .. 4));
- Put_Line ("Clock rate :" & Clock_Rate (Dev)'Img);
- Put_Line ("Device copy overlap : " & Copy_Overlap (Dev)'Img);
- Put_Line ("Kernel exec timeout : " & Kernel_Exec_Timeout (Dev)'Img);
- Put_Line ("Total global mem :" & Total_Global_Mem (Dev)'Img);
- Put_Line ("Total constant mem :" & Total_Constant_Mem (Dev)'Img);
- Put_Line ("Max mem pitch :" & Max_Mem_Pitch (Dev)'Img);
- Put_Line ("Texture alignment :" & Texture_Alignment (Dev)'Img);
- Put_Line ("Multiprocessor count :" & Multiprocessor_Count (Dev)'Img);
- Put_Line ("Shared mem per mp :" & Shared_Mem_Per_Block (Dev)'Img);
- Put_Line ("Registers per mp :" & Regs_Per_Block (Dev)'Img);
- Put_Line ("Threads in warp :" & Warp_Size (Dev)'Img);
- Put_Line ("Max threads per block :" & Max_Threads_Per_Block (Dev)'Img);
- Put_Line ("Max thread dimensions : ("
- & MTD (1)'Img & "," & MTD (2)'Img & "," & MTD (3)'Img & " )");
- Put_Line ("Max grid size : ("
- & MGS (1)'Img & "," & MGS (2)'Img & "," & MGS (3)'Img & " )");
- end Print_Device;
-begin
- Ada.Text_IO.Put_Line ("Found" & Device_Count'Img & " CUDA device(s):");
- Iterate (Process => Print_Device'Access);
-end Enum_Devices;