Skip to content
Browse files

Working on Min -> Minimum rename.

I plan to release this to CPAN under CUDA::Minimal, not CUDA::Min,
since, as Chris Marshall pointed out, CUDA::Min could be ambiguous.
I am in the middle of this work, though, and I have not tested it.
  • Loading branch information...
1 parent 801ef1e commit 64d3b84d5fad524581ba23965f84dea566147498 @run4flat committed Jun 27, 2011
View
4 Build.PL
@@ -1,6 +1,6 @@
use Module::Build;
my $build = Module::Build->new(
- module_name => 'CUDA::Min',
+ module_name => 'CUDA::Minimal',
license => 'perl',
build_requires => {
'ExtUtils::nvcc' => '0.01',
@@ -10,7 +10,7 @@ my $build = Module::Build->new(
'perl' => '0',
},
dist_author => 'David Mertens <dcmertens.perl@gmail.com>',
- config => {cc => 'perl_nvcc', ld => 'perl_nvcc'},
+ config => {ExtUtils::nvcc::MB},
include_dirs => '.',
);
View
8 MANIFEST
@@ -1,8 +1,8 @@
Build.PL
-lib/CUDA/Min.pm
-lib/CUDA/Min.xs
-lib/CUDA/Min/Tests.pm
-lib/CUDA/Min/Tests.xs
+lib/CUDA/Minimal.pm
+lib/CUDA/Minimal.xs
+lib/CUDA/Minimal/Tests.pm
+lib/CUDA/Minimal/Tests.xs
MANIFEST This list of files
mytest.pl
ppport.h
View
4 README
@@ -1,5 +1,5 @@
-CUDA-Min version 0.01
-=====================
+CUDA-Minimal version 0.01
+=========================
The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
View
32 lib/CUDA/Min.pm → lib/CUDA/Minimal.pm
@@ -1,4 +1,4 @@
-package CUDA::Min;
+package CUDA::Minimal;
use 5.010001;
use strict;
@@ -39,11 +39,11 @@ sub is_an_object ($) {
=head1 NAME
-CUDA::Min - A minimal set of Perl bindings for CUDA.
+CUDA::Minimal - A minimal set of Perl bindings for CUDA.
=head1 SYNOPSIS
- use CUDA::Min;
+ use CUDA::Minimal;
# Create a host-side array of 10 sequential
# single-precision floating-point values:
my $N_values = 10;
@@ -105,7 +105,7 @@ CUDA::Min - A minimal set of Perl bindings for CUDA.
# The order of inclusion is not important:
use PDL;
- use CUDA::Min;
+ use CUDA::Minimal;
use PDL::NiceSlice;
# Create a double array of 20 sequential elements:
@@ -287,7 +287,7 @@ is CUDA's reason, not mine.)
Usage example:
- use CUDA::Min;
+ use CUDA::Minimal;
my $data = pack('f*', 1..10);
my $dev_input_ptr = MallocFrom($data);
my $dev_output_ptr = Malloc($data);
@@ -876,7 +876,7 @@ sub ThereAreCudaErrors () {
}
require XSLoader;
-XSLoader::load('CUDA::Min', $VERSION);
+XSLoader::load('CUDA::Minimal', $VERSION);
##############################
# OBJECT ORIENTED INTERFACES #
@@ -886,7 +886,7 @@ XSLoader::load('CUDA::Min', $VERSION);
The documentation made many references to objects that mimic device or host
memory. Objects that 'mimic' device or host memory have a handful of methods
-that C<CUDA::Min> expects to be able to call on them.
+that C<CUDA::Minimal> expects to be able to call on them.
=head2 Host memory
@@ -952,7 +952,7 @@ or nothing at all.
=head1 PDL METHODS
-As an illustration of an object-oriented interface, CUDA::Min supports using
+As an illustration of an object-oriented interface, CUDA::Minimal supports using
piddles in its arguments. It provides two
PDL methods for data transfer, L</send_to> and L</get_from>, and another method
for getting and setting the number of bytes, L</nbytes>. Both of the transfer
@@ -1343,22 +1343,22 @@ functions exported if you wish.
If you're a purist and don't want anything in your current package, there's
nothing stopping you from saying
- use CUDA::Min '';
+ use CUDA::Minimal '';
which won't import anything. If you only want one or two functions, you can
get at them with their fully-qualified name, like this:
- my $error_string = CUDA::Min::GetLastError;
+ my $error_string = CUDA::Minimal::GetLastError;
or you can import specific functions by name:
- use CUDA::Min qw(GetLastError);
+ use CUDA::Minimal qw(GetLastError);
=head2 Memory functions
You can export the memory-related functions using the C<:memory> tag, like so:
- use CUDA::Min qw(:memory);
+ use CUDA::Minimal qw(:memory);
That will make L</Malloc>, L</MallocFrom>, L</Transfer>, and L</Free> available.
@@ -1368,23 +1368,23 @@ Suppose you have some module that invokes various CUDA stuff for you. It handles
all of the memory internally. If you want to benchmark that code, you will
want L</ThreadSynchronize>, which you get by either of the following:
- use CUDA::Min ':sync';
- use CUDA::Min 'ThreadSynchronize';
+ use CUDA::Minimal ':sync';
+ use CUDA::Minimal 'ThreadSynchronize';
=head2 Error functions
If you want to have access to the error-handling functions L</GetLastError>
and L</ThereAreCudaErrors>, you can use the C<:error> tag:
- use CUDA::Min qw(:error);
+ use CUDA::Minimal qw(:error);
=head2 Utility functions
The functions for setting the size of host memory or determining the size of
an allocation are L</SetSize> and L</Sizeof>. You can import those using the
C<:util> tag:
- use CUDA::Min ':util';
+ use CUDA::Minimal ':util';
=head1 TODO
View
2 lib/CUDA/Min.xs → lib/CUDA/Minimal.xs
@@ -4,7 +4,7 @@
#include "ppport.h"
-MODULE = CUDA::Min PACKAGE = CUDA::Min
+MODULE = CUDA::Minimal PACKAGE = CUDA::Minimal
void
_free(SV * dev_ptr_SV)
View
12 lib/CUDA/Min/Tests.pm → lib/CUDA/Minimal/Tests.pm
@@ -1,24 +1,24 @@
=head1 NAME
-CUDA::Min::Tests - a collection of tests for CUDA::Min.
+CUDA::Minimal::Tests - a collection of tests for CUDA::Minimal.
=head1 USAGE
-This provides a couple of CUDA kernels used in the CUDA::Min test suite.
+This provides a couple of CUDA kernels used in the CUDA::Minimal test suite.
You probably won't have need for any of these, unless you want to take a look at
the XS code in Test.xs for an idea of how to wrap CUDA kernel calls.
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2010 by David Mertens
+Copyright (C) 2010, 2011 by David Mertens
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.1 or,
at your option, any later version of Perl 5 you may have available.
=cut
-package CUDA::Min::Tests;
+package CUDA::Minimal::Tests;
use 5.010001;
use strict;
@@ -30,9 +30,9 @@ BEGIN {
our $VERSION = '0.01';
require XSLoader;
-XSLoader::load('CUDA::Min::Tests', $VERSION);
+XSLoader::load('CUDA::Minimal::Tests', $VERSION);
-use CUDA::Min;
+use CUDA::Minimal;
use Carp 'croak';
#####################
View
10 lib/CUDA/Min/Tests.xs → lib/CUDA/Minimal/Tests.xs
@@ -2,6 +2,8 @@
#include "perl.h"
#include "XSUB.h"
+// See Tests.pm for the associated copyright and license details.
+
#include "ppport.h"
//////////////////////////////////
@@ -20,7 +22,7 @@
#define N_LAYERS 8
// This is part of a hack prevent the BOOT section from being included in
-// Min.xs's boot section, an error I do not understand at all:
+// Minimum.xs's boot section, an error I do not understand at all:
#define TESTS_BOOT
/////////////////
@@ -206,19 +208,19 @@ float divide_and_conquer_sum (float * data, int length) {
+ divide_and_conquer_sum(data + length, length));
}
-MODULE = CUDA::Min::Tests PACKAGE = CUDA::Min::Tests
+MODULE = CUDA::Minimal::Tests PACKAGE = CUDA::Minimal::Tests
########################
# Export the constants #
########################
BOOT:
-// This boot seciton does NOT belong in Min.c, but it somehow ends up there
+// This boot seciton does NOT belong in Minimal.c, but it somehow ends up there
// anyway! This #ifdef prevents stupidity from happening:
#ifdef TESTS_BOOT
# Add the preprocessor constants to the namespace:
HV * stash;
- stash = gv_stashpv("CUDA::Min::Tests", TRUE);
+ stash = gv_stashpv("CUDA::Minimal::Tests", TRUE);
newCONSTSUB(stash, "N_THREADS", newSViv( N_THREADS ));
newCONSTSUB(stash, "MIN_PER_BLOCK", newSViv( MIN_PER_BLOCK ));
newCONSTSUB(stash, "N_LAYERS", newSViv( N_LAYERS ));
View
2 mytest.pl
@@ -2,7 +2,7 @@
use strict;
use warnings;
use blib;
-use CUDA::Min;
+use CUDA::Minimal;
use feature 'say';
SetSize(my $test_scalar, Sizeof(f => 30));
View
4 t/00_load.t
@@ -2,7 +2,7 @@
use Test::More tests => 2;
-use_ok('CUDA::Min');
-use_ok('CUDA::Min::Tests');
+use_ok('CUDA::Minimal');
+use_ok('CUDA::Minimal::Tests');
View
2 t/Index-Manipulation.t
@@ -1,7 +1,7 @@
# A set of tests for the index manipulation functions.
use Test::More tests => 7;
-use CUDA::Min;
+use CUDA::Minimal;
# Check that Sizeof computes values correctly, and croaks on bad input:
ok(Sizeof(c => 20) == 20, "20 chars take 20 bytes");
View
2 t/Memory.t
@@ -1,7 +1,7 @@
# A collection of tests for the memory functions
use Test::More tests => 8;
-use CUDA::Min;
+use CUDA::Minimal;
use strict;
use warnings;
View
2 t/Transfer.t
@@ -1,7 +1,7 @@
# A collection of tests for the Transfer function
use Test::More tests => 21;
-use CUDA::Min;
+use CUDA::Minimal;
use strict;
use warnings;
View
12 t/z_PDL.t
@@ -1,9 +1,9 @@
-# Tests for the PDL functionality of CUDA::Min
+# Tests for the PDL functionality of CUDA::Minimal
use strict;
use warnings;
use Test::More;
-use CUDA::Min;
+use CUDA::Minimal;
# Put this in a begin block so that I don't get to the NiceSlice include
# if PDL is not on their machine.
@@ -24,9 +24,9 @@ use PDL::NiceSlice;
my $data = sequence(50);
my $slice = $data(0:9);
-ok(CUDA::Min::_piddle_is_mmap_or_slice($slice),
+ok(CUDA::Minimal::_piddle_is_mmap_or_slice($slice),
"Utility function correctly identifies slice");
-ok(!CUDA::Min::_piddle_is_mmap_or_slice($data),
+ok(!CUDA::Minimal::_piddle_is_mmap_or_slice($data),
"Utility function correctly identifies non-slice");
use PDL::IO::FastRaw;
@@ -37,7 +37,7 @@ SKIP:
{
my $mmap = eval {mapfraw $test_fname};
skip('because PDL does not support mmap for your system', 1) if $@;
- ok(CUDA::Min::_piddle_is_mmap_or_slice($mmap),
+ ok(CUDA::Minimal::_piddle_is_mmap_or_slice($mmap),
"Utility function correctly identifies mmap");
}
@@ -55,7 +55,7 @@ $results(0:9) .= -1;
ok(all($data == $results), 'Direct data updates work');
# Data should still not be considered a slice
-ok(!CUDA::Min::_piddle_is_mmap_or_slice($data),
+ok(!CUDA::Minimal::_piddle_is_mmap_or_slice($data),
"Utility function still correctly identifies non-slice");
View
28 t/z_kernel_invocations.t
@@ -2,10 +2,10 @@ use Test::More tests => 25;
# This file starts with z_ to ensure that it runs last.
-# Load CUDA::Min::Tests, which provides functions to facilitate testing
+# Load CUDA::Minimal::Tests, which provides functions to facilitate testing
# kernel invocations:
-use CUDA::Min;
-use CUDA::Min::Tests;
+use CUDA::Minimal;
+use CUDA::Minimal::Tests;
use strict;
use warnings;
@@ -16,7 +16,7 @@ is($string, 'no error', "With no error, GetLastError should return 'no error'");
ok(not (ThereAreCudaErrors), 'ThereAreCudaErrors should return false when there are none');
ok($@ eq '', 'ThereAreCudaErrors does not set $@ when there are no problems');
# Make sure the kernel that's supposed to always succeed does, in fact, succeed:
-CUDA::Min::Tests::succeed_test();
+CUDA::Minimal::Tests::succeed_test();
ok(not (defined ThereAreCudaErrors), 'succeed_test does not set a CUDA error');
# Create a collection of values to sum and copy them to the device:
@@ -26,7 +26,7 @@ my $dev_ptr = MallocFrom($host_array);
# Run the multiply kernel; copy back 10 random values and make sure they are
# what they are supposed to be:
-CUDA::Min::Tests::cuda_multiply_by_constant($dev_ptr, $N_elements, 4);
+CUDA::Minimal::Tests::cuda_multiply_by_constant($dev_ptr, $N_elements, 4);
my $test_val = pack 'f', 1;
for (1..10) {
my $offset = int rand $N_elements;
@@ -35,21 +35,21 @@ for (1..10) {
}
# Return the values to their original state:
-CUDA::Min::Tests::cuda_multiply_by_constant($dev_ptr, $N_elements, 0.25);
+CUDA::Minimal::Tests::cuda_multiply_by_constant($dev_ptr, $N_elements, 0.25);
# Test the sum:
-CUDA::Min::Tests::sum_reduce_test($host_array, $dev_ptr, 'a single block');
-CUDA::Min::Tests::sum_reduce_test($host_array, $dev_ptr, '32 blocks', 32);
+CUDA::Minimal::Tests::sum_reduce_test($host_array, $dev_ptr, 'a single block');
+CUDA::Minimal::Tests::sum_reduce_test($host_array, $dev_ptr, '32 blocks', 32);
# Free the current device memory before moving forward:
Free($dev_ptr);
# Now I'm going to try a nontrivial sum of 65536 floats:
$host_array = pack 'f*', map {sin ($_/10)} 1..65536;
$dev_ptr = MallocFrom($host_array);
-CUDA::Min::Tests::sum_reduce_test($host_array, $dev_ptr, 'single block sine-sum');
-CUDA::Min::Tests::sum_reduce_test($host_array, $dev_ptr, '32 block sine-sum', 32);
-CUDA::Min::Tests::sum_reduce_test($host_array, $dev_ptr, '1024,32 block sine-sum', 1024, 32);
+CUDA::Minimal::Tests::sum_reduce_test($host_array, $dev_ptr, 'single block sine-sum');
+CUDA::Minimal::Tests::sum_reduce_test($host_array, $dev_ptr, '32 block sine-sum', 32);
+CUDA::Minimal::Tests::sum_reduce_test($host_array, $dev_ptr, '1024,32 block sine-sum', 1024, 32);
# Don't forget to clean up:
Free($dev_ptr);
@@ -64,7 +64,7 @@ Free($dev_ptr);
# GetLastError and the documentation should be updated accordingly.
# Run the kernel that is supposed to fail and see what we get:
-CUDA::Min::Tests::fail_test();
+CUDA::Minimal::Tests::fail_test();
ThreadSynchronize();
ok(ThereAreCudaErrors, "ThereAreCudaErrors returns a true value when an error occurs");
# Check that ThereAreCudaErrors sets $@
@@ -76,13 +76,13 @@ $@ = '';
ok(not (defined ThereAreCudaErrors), "ThereAreCudaErrors clears the last error");
# Check that the next kernel invocation trips an error
-CUDA::Min::Tests::succeed_test();
+CUDA::Minimal::Tests::succeed_test();
ok(ThereAreCudaErrors, "Good kernels invoked after a failed kernel launch also fail");
like($@, qr/unspecified/, 'ThereAreCudaErrors properly sets $@ on error');
$@ = '';
# Check the return value of GetLastError:
-CUDA::Min::Tests::succeed_test();
+CUDA::Minimal::Tests::succeed_test();
like(GetLastError, qr/unspecified/, 'Further kernel invocations return an unspecified launch failure');

0 comments on commit 64d3b84

Please sign in to comment.
Something went wrong with that request. Please try again.