New Upstream Snapshot - ruby-mpi
Ready changes
Summary
Merged new upstream version: 0.3.2+git20210714.1.fed22f9 (was: 0.3.2).
Resulting package
Built on 2022-12-20T15:15 (took 8m4s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots ruby-mpi-dbgsymapt install -t fresh-snapshots ruby-mpi
Lintian Result
- ruby-mpi-dbgsym_0.3.2+git20210714.1.fed22f9-1~jan+nus3_amd64.deb
- ruby-mpi_0.3.2+git20210714.1.fed22f9-1~jan+nus3.dsc
- ruby-mpi_0.3.2+git20210714.1.fed22f9-1~jan+nus3_amd64.buildinfo
- ruby-mpi_0.3.2+git20210714.1.fed22f9-1~jan+nus3_amd64.deb
- ruby-mpi_0.3.2+git20210714.1.fed22f9-1~jan+nus3_amd64.changes
Diff
diff --git a/debian/changelog b/debian/changelog
index 2c87922..249d452 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ruby-mpi (0.3.2+git20210714.1.fed22f9-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+ * Drop patch 0005-Fixnum-to-Integer.patch, present upstream.
+
+ -- Debian Janitor <janitor@jelmer.uk> Tue, 20 Dec 2022 15:10:00 -0000
+
ruby-mpi (0.3.2-4) unstable; urgency=medium
* Team upload.
diff --git a/debian/patches/0001-Fix-NArray-PATH.patch b/debian/patches/0001-Fix-NArray-PATH.patch
index 6dfd1aa..42fe9ee 100644
--- a/debian/patches/0001-Fix-NArray-PATH.patch
+++ b/debian/patches/0001-Fix-NArray-PATH.patch
@@ -8,10 +8,10 @@ Author: Youhei SASAKI <uwabami@gfd-dennou.org>
ext/mpi/extconf.rb | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
-diff --git a/ext/mpi/extconf.rb b/ext/mpi/extconf.rb
-index f01c14d..ca4a82d 100644
---- a/ext/mpi/extconf.rb
-+++ b/ext/mpi/extconf.rb
+Index: ruby-mpi.git/ext/mpi/extconf.rb
+===================================================================
+--- ruby-mpi.git.orig/ext/mpi/extconf.rb
++++ ruby-mpi.git/ext/mpi/extconf.rb
@@ -1,25 +1,7 @@
require "mkmf"
diff --git a/debian/patches/0002-Drop-RubyGems-Depends.patch b/debian/patches/0002-Drop-RubyGems-Depends.patch
index faa3c64..1ab55f4 100644
--- a/debian/patches/0002-Drop-RubyGems-Depends.patch
+++ b/debian/patches/0002-Drop-RubyGems-Depends.patch
@@ -8,15 +8,16 @@ Author: Youhei SASAKI <uwabami@gfd-dennou.org>
lib/mpi.rb | 4 ----
1 file changed, 4 deletions(-)
-diff --git a/lib/mpi.rb b/lib/mpi.rb
-index 299acc5..4f799ae 100644
---- a/lib/mpi.rb
-+++ b/lib/mpi.rb
-@@ -1,7 +1,3 @@
--begin
+Index: ruby-mpi.git/lib/mpi.rb
+===================================================================
+--- ruby-mpi.git.orig/lib/mpi.rb
++++ ruby-mpi.git/lib/mpi.rb
+@@ -1,8 +1,4 @@
+ begin
- require "rubygems"
-rescue LoadError
-end
- begin
+-begin
require "numru/narray"
rescue LoadError
+ err = $!
diff --git a/debian/patches/0003-Fix-spec-test-loader-for-Debianize.patch b/debian/patches/0003-Fix-spec-test-loader-for-Debianize.patch
index 375d295..8bf7b67 100644
--- a/debian/patches/0003-Fix-spec-test-loader-for-Debianize.patch
+++ b/debian/patches/0003-Fix-spec-test-loader-for-Debianize.patch
@@ -11,10 +11,10 @@ Author: Youhei SASAKI <uwabami@gfd-dennou.org>
3 files changed, 2 insertions(+), 16 deletions(-)
delete mode 100644 spec/spec_helper.rb
-diff --git a/spec/ruby-mpi_spec.rb b/spec/ruby-mpi_spec.rb
-index 4f524c7..ff5d004 100644
---- a/spec/ruby-mpi_spec.rb
-+++ b/spec/ruby-mpi_spec.rb
+Index: ruby-mpi.git/spec/ruby-mpi_spec.rb
+===================================================================
+--- ruby-mpi.git.orig/spec/ruby-mpi_spec.rb
++++ ruby-mpi.git/spec/ruby-mpi_spec.rb
@@ -1,4 +1,5 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+require 'rspec'
@@ -22,10 +22,9 @@ index 4f524c7..ff5d004 100644
if defined?(NumRu::NArray)
include NumRu
-diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
-deleted file mode 100644
-index 489f71d..0000000
---- a/spec/spec_helper.rb
+Index: ruby-mpi.git/spec/spec_helper.rb
+===================================================================
+--- ruby-mpi.git.orig/spec/spec_helper.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'ext', 'mpi'))
@@ -41,10 +40,10 @@ index 489f71d..0000000
-RSpec.configure do |config|
-
-end
-diff --git a/test/test_utils.rb b/test/test_utils.rb
-index c8785d1..49c8b1c 100644
---- a/test/test_utils.rb
-+++ b/test/test_utils.rb
+Index: ruby-mpi.git/test/test_utils.rb
+===================================================================
+--- ruby-mpi.git.orig/test/test_utils.rb
++++ ruby-mpi.git/test/test_utils.rb
@@ -1,6 +1,4 @@
require "test/unit"
-
diff --git a/debian/patches/0004-Drop-NA_LLINT-NArray-type.patch b/debian/patches/0004-Drop-NA_LLINT-NArray-type.patch
index 7ee0e90..76b21d5 100644
--- a/debian/patches/0004-Drop-NA_LLINT-NArray-type.patch
+++ b/debian/patches/0004-Drop-NA_LLINT-NArray-type.patch
@@ -8,11 +8,11 @@ ruby-narray 0.6.1.2-3 does not support this type.
ext/mpi/mpi.c | 4 ----
1 file changed, 4 deletions(-)
-diff --git a/ext/mpi/mpi.c b/ext/mpi/mpi.c
-index f690c4a..7e78607 100644
---- a/ext/mpi/mpi.c
-+++ b/ext/mpi/mpi.c
-@@ -52,10 +52,6 @@
+Index: ruby-mpi.git/ext/mpi/mpi.c
+===================================================================
+--- ruby-mpi.git.orig/ext/mpi/mpi.c
++++ ruby-mpi.git/ext/mpi/mpi.c
+@@ -56,10 +56,6 @@
typ = NA_MPI_LINT;\
buffer = (void*)((char*)buffer + off*4);\
break;\
diff --git a/debian/patches/0005-Fixnum-to-Integer.patch b/debian/patches/0005-Fixnum-to-Integer.patch
deleted file mode 100644
index bddc8f1..0000000
--- a/debian/patches/0005-Fixnum-to-Integer.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From: Youhei SASAKI <uwabami@gfd-dennou.org>
-Date: Wed, 19 Feb 2020 17:10:45 +0900
-Subject: Fixnum to Integer
-Forwarded: https://github.com/gfd-dennou-club/ruby-mpi/issues/4
-Applied-Upstream: https://github.com/gfd-dennou-club/ruby-mpi/commit/514c0c969f2e0b728fd1b58b7f901b947d6caa75
-
-Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
----
- spec/ruby-mpi_spec.rb | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/spec/ruby-mpi_spec.rb b/spec/ruby-mpi_spec.rb
-index ff5d004..35111f7 100644
---- a/spec/ruby-mpi_spec.rb
-+++ b/spec/ruby-mpi_spec.rb
-@@ -18,13 +18,13 @@ describe "MPI" do
- end
-
- it "should give version" do
-- expect(MPI::VERSION.class).to eq(Fixnum)
-- expect(MPI::SUBVERSION.class).to eq(Fixnum)
-+ expect(MPI::VERSION.class).to eq(Integer)
-+ expect(MPI::SUBVERSION.class).to eq(Integer)
- end
-
- it "should give rank and size" do
-- expect(@world.rank.class).to eql(Fixnum)
-- expect(@world.size.class).to eql(Fixnum)
-+ expect(@world.rank.class).to eql(Integer)
-+ expect(@world.size.class).to eql(Integer)
- expect(@world.size).to be > 0
- end
-
diff --git a/debian/patches/0006-Use-narray-instead-of-numru-narray.patch b/debian/patches/0006-Use-narray-instead-of-numru-narray.patch
index 70f8651..2163328 100644
--- a/debian/patches/0006-Use-narray-instead-of-numru-narray.patch
+++ b/debian/patches/0006-Use-narray-instead-of-numru-narray.patch
@@ -9,9 +9,11 @@ Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
ruby-mpi.gemspec | 7 +++----
2 files changed, 4 insertions(+), 5 deletions(-)
---- a/Gemfile
-+++ b/Gemfile
-@@ -2,7 +2,7 @@
+Index: ruby-mpi.git/Gemfile
+===================================================================
+--- ruby-mpi.git.orig/Gemfile
++++ ruby-mpi.git/Gemfile
+@@ -2,7 +2,7 @@ source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
@@ -20,9 +22,11 @@ Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
---- a/ruby-mpi.gemspec
-+++ b/ruby-mpi.gemspec
-@@ -50,14 +50,14 @@
+Index: ruby-mpi.git/ruby-mpi.gemspec
+===================================================================
+--- ruby-mpi.git.orig/ruby-mpi.gemspec
++++ ruby-mpi.git/ruby-mpi.gemspec
+@@ -50,14 +50,14 @@ Gem::Specification.new do |s|
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -39,7 +43,7 @@ Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
s.add_dependency(%q<rspec>, [">= 2.3.0"])
s.add_dependency(%q<bundler>, [">= 1.0.0"])
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
-@@ -65,7 +65,7 @@
+@@ -65,7 +65,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<rake-compiler>, [">= 0"])
end
else
@@ -48,7 +52,7 @@ Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
s.add_dependency(%q<rspec>, [">= 2.3.0"])
s.add_dependency(%q<bundler>, [">= 1.0.0"])
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
-@@ -73,4 +73,3 @@
+@@ -73,4 +73,3 @@ Gem::Specification.new do |s|
s.add_dependency(%q<rake-compiler>, [">= 0"])
end
end
diff --git a/debian/patches/series b/debian/patches/series
index 84a4f91..061f36a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,5 +2,4 @@
0002-Drop-RubyGems-Depends.patch
0003-Fix-spec-test-loader-for-Debianize.patch
0004-Drop-NA_LLINT-NArray-type.patch
-0005-Fixnum-to-Integer.patch
0006-Use-narray-instead-of-numru-narray.patch
diff --git a/ext/mpi/mpi.c b/ext/mpi/mpi.c
index f690c4a..b91f534 100644
--- a/ext/mpi/mpi.c
+++ b/ext/mpi/mpi.c
@@ -27,6 +27,10 @@
---->> Please define NA_MPI_LLINT manually because sizeof(long long) != 8. <<----
#endif
+#ifndef NARRAY_BIGMEM
+# define NA_LLINT -999
+#endif
+
#define OBJ2C(rb_obj, len, buffer, typ, off) \
{\
@@ -465,6 +469,8 @@ rb_comm_gather(VALUE self, VALUE rb_sendbuf, VALUE rb_recvbuf, VALUE rb_root)
if (recvcount < sendcount*size)
rb_raise(rb_eArgError, "recvbuf is too small");
recvcount = sendcount;
+ } else {
+ recvtype = sendtype; // to avoid segmentation fault in a environment
}
check_error(MPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm->Comm));
return Qnil;
diff --git a/samples/kmeans.rb b/samples/kmeans.rb
new file mode 100644
index 0000000..392c60c
--- /dev/null
+++ b/samples/kmeans.rb
@@ -0,0 +1,137 @@
+# Run this program using
+#
+# mpirun -np numprocs ruby kmeans.rb numpoints numclusters
+#
+# where numprocs, numpoints and numclusters are integers
+# and numprocs <= numpoints and numclusters <= numpoints
+#
+# Parallelization assumes that numclusters << numpoints
+# and that numprocs << numpoints
+#
+# The program is based on the description at
+# https://en.wikipedia.org/wiki/K-means_clustering
+
+require "mpi"
+if defined?(NumRu::NArray)
+ include NumRu
+end
+
+def generate_points count
+ x = NArray.float(count).random
+ y = NArray.float(count).random
+ return x , y
+end
+
+MPI.Init
+
+world = MPI::Comm::WORLD
+
+size = world.size
+rank = world.rank
+
+def usage(rank)
+ if rank==0
+ print <<EOF
+Usage: mpirun -np numproc ruby #$0 numpoints numclusters
+
+ numpoints and numclusters must be integers > 0
+ numclusters <= numpoints and numproc <= numpoints
+EOF
+ end
+ MPI.Finalize
+ exit -1
+end
+
+usage(rank) if ARGV.length != 2
+usage(rank) if ( ( /^\d+$/ =~ ARGV[0] ) != 0)
+usage(rank) if ( ( /^\d+$/ =~ ARGV[1] ) != 0)
+n_points = ARGV[0].to_i
+n_clusters = ARGV[1].to_i
+usage(rank) unless n_points > size
+usage(rank) unless n_clusters > 0
+usage(rank) unless n_points >= n_clusters
+
+my_points = n_points.div(size)
+if ( n_points % size > rank )
+ my_points += 1
+end
+
+cluster_x = NArray.float(n_clusters)
+cluster_y = NArray.float(n_clusters)
+my_cluster = NArray.int(my_points)
+min_distance = NArray.float(my_points)
+distance = NArray.float(n_clusters)
+cluster_member_count = NArray.int(n_clusters)
+total_cluster_x_sum = NArray.float(n_clusters)
+total_cluster_y_sum = NArray.float(n_clusters)
+total_cluster_member_count = NArray.int(n_clusters)
+my_cluster_x = NArray.float(n_clusters)
+my_cluster_y = NArray.float(n_clusters)
+my_cluster_member_count = NArray.int(n_clusters)
+my_energy = NArray.float(1)
+total_energy = NArray.float(1)
+random_x = NArray.float(n_clusters)
+random_y = NArray.float(n_clusters)
+
+my_x, my_y = generate_points my_points
+if rank == 0
+ cluster_x, cluster_y = generate_points n_clusters
+end
+world.Bcast(cluster_x,0)
+world.Bcast(cluster_y,0)
+
+iter = 0
+# Do 10 iterations for testing purposes
+# in practice would use some convergence
+# criteria
+while iter < 10 do
+ # Find cluster and calculate energy
+ i = 0
+ my_energy[0] = 0
+ while i < my_points do
+ distance = ( cluster_x - my_x[i] )**2 + ( cluster_y - my_y[i] )**2
+ min_distance = distance.min
+ my_energy[0] += min_distance
+ # If multiple minimum values, take the first one
+ my_cluster[i] = distance.eq(min_distance).where[0]
+ i +=1
+ end
+ world.Allreduce(my_energy,total_energy,MPI::Op::SUM)
+ if rank == 0
+ p total_energy[0]
+ end
+ # Find new cluster centroids
+ j = 0
+ while j < n_clusters do
+ mask = my_cluster.eq(j)
+ my_cluster_member_count[j] = mask.count_true
+ if mask.any?
+ my_cluster_x[j] = (my_x[mask]).sum
+ my_cluster_y[j] = (my_y[mask]).sum
+ end
+ j +=1
+ end
+ world.Allreduce(my_cluster_member_count,total_cluster_member_count,MPI::Op::SUM)
+ world.Allreduce(my_cluster_x,total_cluster_x_sum,MPI::Op::SUM)
+ world.Allreduce(my_cluster_y,total_cluster_y_sum,MPI::Op::SUM)
+ # If a cluster is empty, choose a random point to try
+ no_members = total_cluster_member_count.eq(0)
+ if no_members.any?
+ if rank == 0
+ random_x, random_y = generate_points no_members.count_true
+ total_cluster_member_count[no_members]= 1
+ total_cluster_x_sum[no_members] = random_x
+ total_cluster_y_sum[no_members] = random_y
+ cluster_x = total_cluster_x_sum / total_cluster_member_count
+ cluster_y = total_cluster_y_sum / total_cluster_member_count
+ end
+ world.Bcast(cluster_x,0)
+ world.Bcast(cluster_y,0)
+ else
+ cluster_x = total_cluster_x_sum / total_cluster_member_count
+ cluster_y = total_cluster_y_sum / total_cluster_member_count
+ end
+iter += 1
+end
+
+MPI.Finalize
diff --git a/samples/pi.rb b/samples/pi.rb
new file mode 100644
index 0000000..d7bcbbd
--- /dev/null
+++ b/samples/pi.rb
@@ -0,0 +1,59 @@
+# Run this program using
+#
+# mpirun -np 2 ruby pi.rb numpoints
+#
+# where numpoints is an integer
+#
+# The program is based on an example from
+# https://carpentries-incubator.github.io/hpc-intro/16-parallel/index.html
+
+require "mpi"
+if defined?(NumRu::NArray)
+ include NumRu
+end
+
+def inside_circle my_count
+ x = NArray.float(my_count).random
+ y = NArray.float(my_count).random
+ a = ((x**2 + y**2) < 1.0)
+ return a.count_true
+end
+
+MPI.Init
+
+world = MPI::Comm::WORLD
+
+size = world.size
+rank = world.rank
+
+def usage(rank)
+ if rank==0
+ print <<EOF
+Usage: mpirun -np numproc ruby #$0 numpoints
+ numpoints must be an integer > 0
+EOF
+ end
+ MPI.Finalize
+ exit -1
+end
+usage(rank) if ARGV.length != 1
+usage(rank) if ( ( /^\d+$/ =~ ARGV[0] ) != 0)
+n_samples = ARGV[0].to_i
+usage(rank) unless n_samples > 0
+
+my_samples = n_samples.div(size)
+if ( n_samples % size > rank )
+ my_samples = my_samples + 1
+end
+
+my_count = NArray[0]
+count = NArray[0]
+
+my_count[0] = inside_circle my_samples
+
+world.Reduce(my_count,count,MPI::Op::SUM,0)
+if ( rank == 0 )
+ p "Pi is approximately " + ((count[0]*4.0)/(1.0*n_samples)).to_s
+end
+
+MPI.Finalize
diff --git a/spec/ruby-mpi_spec.rb b/spec/ruby-mpi_spec.rb
index 4f524c7..cf2ad42 100644
--- a/spec/ruby-mpi_spec.rb
+++ b/spec/ruby-mpi_spec.rb
@@ -17,13 +17,13 @@ describe "MPI" do
end
it "should give version" do
- expect(MPI::VERSION.class).to eq(Fixnum)
- expect(MPI::SUBVERSION.class).to eq(Fixnum)
+ expect(MPI::VERSION.class).to eq(Integer)
+ expect(MPI::SUBVERSION.class).to eq(Integer)
end
it "should give rank and size" do
- expect(@world.rank.class).to eql(Fixnum)
- expect(@world.size.class).to eql(Fixnum)
+ expect(@world.rank.class).to eql(Integer)
+ expect(@world.size.class).to eql(Integer)
expect(@world.size).to be > 0
end
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/lib/debug/.build-id/bc/02b7de8f28814623d15259c35f5522bf0e2312.debug -rw-r--r-- root/root /usr/lib/debug/.build-id/fe/cfa92a9de07817750e1724db7286d4dbe0bbb2.debug -rw-r--r-- root/root /usr/lib/debug/.dwz/x86_64-linux-gnu/ruby-mpi.debug -rw-r--r-- root/root /usr/lib/x86_64-linux-gnu/ruby/vendor_ruby/3.0.0/mpi.so -rw-r--r-- root/root /usr/share/rubygems-integration/3.0.0/specifications/ruby-mpi-0.3.2.gemspec
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/lib/debug/.build-id/d0/1c787cde1d60e3e9964ff8ac732d06f3a6fab7.debug
Control files of package ruby-mpi: lines which differ (wdiff format)
Depends: ruby-narray, libc6 (>= 2.4), libopenmpi3 (>= 4.1.4), libruby3.0 (>= 3.0.0~preview1) | libruby3.1 (>= 3.1.0~preview1), libruby (>= 1:3.0~0) | libruby (>= 1:3.1~0), libruby (<< 1:3.2~)
Control files of package ruby-mpi-dbgsym: lines which differ (wdiff format)
Build-Ids: d01c787cde1d60e3e9964ff8ac732d06f3a6fab7 bc02b7de8f28814623d15259c35f5522bf0e2312 fecfa92a9de07817750e1724db7286d4dbe0bbb2