Creating new port math/sprng: could need some help

Rainer Hurling rhurlin at gwdg.de
Sun Jan 16 18:12:33 UTC 2011


I am trying to create a port of SPRNG version 2, the Scalable Parallel 
Pseudo Random Number Generators Library ( http://sprng.cs.fsu.edu/ ).

There is a newer version 4 of SPRNG (not in the ports), but version 2 is 
needed for some stuff like math/R (with packages rsprng, Rmpi etc.), 
because API changed heavily afterwards.

I have only little experience in creating ports and there are some 
issues with SPRNG I could need help on. What I get until now is a port 
skeleton which is able to

(1) download and extract the tarball: I named the port 'sprng-2.0b'. Is 
it better to rename it in 'libsprng-2.0b' or something like this? As 
category I choosed 'math' and 'parallel'.

(2) build dependencies: The main dependencies seem to be math/gmp, 
net/mpich2 (and lang/gcc4x because of fortran, see below).

(3) patch some files: Is there a way to create a <newline> with 
@${REINPLACE_CMD} in Makefile to add another #include?

(4) get the library and testbinaries build and installed: The sources 
seem to be incompletely in some way. Only building of static library 
'libsprng.a' and no target for installing the library and testfiles was 
included. Looking around I found a way to also compile a shared library 
and get it installed (after creating an install target) and registered. 
I assume there is a more common way to do this?

The installed library works as expected for simple tasks. It is also 
regocnized by other tools who need it.

Beside this the port should support MPI (net/mpich2) and fortran 
(gcc44/gcc45/gcc46?), see sources. For MPI there are already some lines 
in the ports Makefile (lines 27-32, commented out). At the moment I had 
to deactivate both because of build failures.

Is someone willing to have a look at this port draft (see attached shar 
file, should be extracted into math/sprng)? I would really appreciate it.

Thanks in advance,
Rainer Hurling


P.S.: There are some comments in the Makefile for better understanding 
in development. Of course they will be removed before submitting any code.

-------------- next part --------------
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile
#	distinfo
#	files
#	files/patch-SRC_make.INTEL
#	files/patch-SRC_sprng_Makefile
#	files/patch-EXAMPLES_checkpoint-simple.c
#	files/patch-EXAMPLES_pi-simple.c
#	files/patch-EXAMPLES_spawn.c
#	files/patch-TESTS_chisquare.c
#	files/patch-TESTS_collisions.c
#	files/patch-TESTS_coupon.c
#	files/patch-TESTS_maxt.c
#	files/patch-TESTS_poker.c
#	files/patch-TESTS_random__walk.c
#	files/patch-TESTS_sum.c
#	files/patch-TESTS_init__tests.c
#	files/patch-SRC_primes__32.c
#	files/patch-SRC_primes__64.c
#	files/patch-EXAMPLES_checkpoint.c
#	pkg-descr
#	pkg-plist
#	pkg-message
#
echo x - Makefile
sed 's/^X//' >Makefile << 'b67911656ef5d18c4ae36cb6741b7965'
X# Ports collection makefile for:   sprng
X# Date created:        05 January 2011
X# Whom:                Rainer Hurling <rhurlin at gwdg.de>
X#
X# $FreeBSD$
X
XPORTNAME=	sprng
XPORTVERSION=	2.0b
XCATEGORIES=	math parallel
XMASTER_SITES=	http://sprng.fsu.edu/Version2.0/
XDISTNAME=	${PORTNAME}${PORTVERSION}
X
XMAINTAINER=	rhurlin at gwdg.de
XCOMMENT=	The Scalable Parallel Random Number Generators Library
X
XLIB_DEPENDS=	gmp.10:${PORTSDIR}/math/gmp \
X		mpich.2:${PORTSDIR}/net/mpich2
X
XWRKSRC=		${WRKDIR}/${PORTNAME}2.0
X
XUSE_LDCONFIG=	yes
X
X.include <bsd.port.pre.mk>
X
Xpost-patch:
X#       [WORKAROUND for testing mpi usage]
X#	@${REINPLACE_CMD} -e 's|#MPIDEF = -DSPRNG_MPI|MPIDEF = -DSPRNG_MPI|' \
X#		${WRKSRC}/make.CHOICES
X#	@${REINPLACE_CMD} -e 's|#MPIDIR = -L/usr/local/mpi/build/LINUX/ch_p4/lib|MPIDIR = -L/usr/local/lib|' \
X#		${WRKSRC}/SRC/make.INTEL
X#	@${REINPLACE_CMD} -e 's|#MPILIB = -lmpich|MPILIB = -lmpich|' \
X#		${WRKSRC}/SRC/make.INTEL
X#       [GMP ready for use]
X	@${REINPLACE_CMD} -e 's|GMPLIB = -lgmp|GMPLIB = -L/usr/local/lib -lgmp|' \
X		${WRKSRC}/make.CHOICES
X	@${REINPLACE_CMD} -e 's|"mpi.h"|<mpi.h>|' \
X		${WRKSRC}/EXAMPLES/pi-simple_mpi.c \
X		${WRKSRC}/TESTS/fft.c \
X		${WRKSRC}/TESTS/sum.c
X#       [Avoid] warning: return type of 'main' is not 'int'
X	@${FIND} ${WRKSRC} -name "*.c" | ${XARGS} ${REINPLACE_CMD} -e \
X		's|void main|int main|g'
X#       [Workaround] poker.c:19: error: 'index' redeclared as different kind of symbol
X	@${REINPLACE_CMD} -e 's|index|indexx|' \
X		${WRKSRC}/TESTS/poker.c
X
Xpre-install:
X	@${REINPLACE_CMD} -e 's|./||' \
X		${WRKSRC}/checksprng \
X		${WRKSRC}/timesprng
X	${MKDIR} ${DATADIR}
X	@${REINPLACE_CMD} -e 's|< gen|< ${DATADIR}/gen|' \
X		${WRKSRC}/checksprng \
X		${WRKSRC}/timesprng
X
X
Xdo-install:
X	${INSTALL_LIB} ${WRKSRC}/lib/libsprng.a $(DESTDIR)/usr/local/lib
X	${INSTALL_LIB} ${WRKSRC}/lib/libsprng.so.2.0 ${PREFIX}/lib
X	${LN} -sf ${PREFIX}/lib/libsprng.so.2.0 ${PREFIX}/lib/libsprng.so.2
X	${LN} -sf ${PREFIX}/lib/libsprng.so.2 ${PREFIX}/lib/libsprng.so
X	(cd ${WRKSRC}/include && ${INSTALL_DATA} sprng.h sprng_f.h interface.h ${PREFIX}/include)
X	${INSTALL} ${WRKSRC}/checksprng ${PREFIX}/bin
X	${INSTALL} ${WRKSRC}/check.csprng ${PREFIX}/bin
X	${INSTALL} ${WRKSRC}/check_sim.csprng ${PREFIX}/bin
X	${INSTALL} ${WRKSRC}/check_ptr.csprng ${PREFIX}/bin
X	${INSTALL} ${WRKSRC}/timesprng ${PREFIX}/bin
X	${INSTALL} ${WRKSRC}/timingcsprng ${PREFIX}/bin
X
Xpost-install:
X	${INSTALL_DATA} ${WRKSRC}/gen* ${DATADIR}
X	${INSTALL_DATA} ${WRKSRC}/DOCS/new_sprng.ps ${DATADIR}
X	@${ECHO_MSG} ""
X	@${CAT} ${PKGMESSAGE}
X	@${ECHO_MSG} ""
X
X.include <bsd.port.post.mk>
b67911656ef5d18c4ae36cb6741b7965
echo x - distinfo
sed 's/^X//' >distinfo << '57677d168a5ec21bdf22c9501f075a8f'
XSHA256 (sprng2.0b.tar.gz) = 8985d7cae4f20f57889bc7ba11dfed226a02057d396731f4a5cc174704131ac2
XSIZE (sprng2.0b.tar.gz) = 1780931
57677d168a5ec21bdf22c9501f075a8f
echo c - files
mkdir -p files > /dev/null 2>&1
echo x - files/patch-SRC_make.INTEL
sed 's/^X//' >files/patch-SRC_make.INTEL << 'a19f7b5f540407a4020afa8f2b84b9cc'
X--- SRC/make.INTEL	2007-01-26 17:30:06.000000000 +0100
X+++ SRC/make.INTEL	2011-01-16 17:13:00.000000000 +0100
X@@ -6,8 +6,8 @@
X CC = gcc
X CLD = $(CC)
X # Set f77 to echo if you do not have a FORTRAN compiler
X-F77 = g77
X-#F77 = echo
X+#F77 = g77
X+F77 = echo
X F77LD = $(F77)
X FFXN = -DAdd__
X FSUFFIX = F
X@@ -27,10 +27,10 @@
X # Please include mpi header file path, if needed
X 
X #CFLAGS = -O3 -DLittleEndian $(PMLCGDEF) $(MPIDEF) -D$(PLAT)  -I/usr/local/mpi/include -I/usr/local/mpi/build/LINUX/ch_p4/include
X-CFLAGS = -O3 -DLittleEndian $(PMLCGDEF) $(MPIDEF) -D$(PLAT)  
X-CLDFLAGS =  -O3 
X+CFLAGS = -O -fpic $(PMLCGDEF) $(MPIDEF) -D$(PLAT) -I/usr/local/include
X+CLDFLAGS =  -O
X #FFLAGS = -O3 $(PMLCGDEF) $(MPIDEF) -D$(PLAT)  -I/usr/local/mpi/include -I/usr/local/mpi/build/LINUX/ch_p4/include -I.
X-FFLAGS = -O3 $(PMLCGDEF) $(MPIDEF) -D$(PLAT)
X-F77LDFLAGS =  -O3 
X+FFLAGS = -O $(PMLCGDEF) $(MPIDEF) -D$(PLAT) -I/usr/local/include -I.
X+F77LDFLAGS =  -O
X 
X CPP = cpp -P
a19f7b5f540407a4020afa8f2b84b9cc
echo x - files/patch-SRC_sprng_Makefile
sed 's/^X//' >files/patch-SRC_sprng_Makefile << '52ba6067d48d96b989dbde185b8c32eb'
X--- SRC/sprng/Makefile
X+++ SRC/sprng/Makefile
X@@ -44,16 +44,23 @@
X $(LIBDIR)/libsprng.a : sprng.o   \
X 		$(SRCDIR)/lcg/lcg.o $(SRCDIR)/lfg/lfg.o \
X 		$(SRCDIR)/lcg64/lcg64.o \
X-		$(SRCDIR)/mlfg/mlfg.o $(SRCDIR)/cmrg/cmrg.o \
X 		$(SRCDIR)/pmlcg/pmlcg.o \
X+		$(SRCDIR)/mlfg/mlfg.o $(SRCDIR)/cmrg/cmrg.o \
X 		$(SPRNG_COMMON_DEPEND)
X 	$(AR) $(ARFLAGS) $(LIBDIR)/libsprng.a sprng.o \
X 		$(SRCDIR)/lcg/lcg.o $(SRCDIR)/lfg/lfg.o \
X 		$(SRCDIR)/lcg64/lcg64.o \
X-		$(SRCDIR)/mlfg/mlfg.o $(SRCDIR)/cmrg/cmrg.o \
X 		$(SRCDIR)/pmlcg/pmlcg.o \
X+		$(SRCDIR)/mlfg/mlfg.o $(SRCDIR)/cmrg/cmrg.o \
X 		$(SPRNG_COMMON_DEPEND)
X 	$(RANLIB) $(LIBDIR)/libsprng.a
X+	$(CC) -shared -Wl,-soname,libsprng.so.2 \
X+		-o $(LIBDIR)/libsprng.so.2.0  sprng.o \
X+		$(SRCDIR)/lcg/lcg.o $(SRCDIR)/lfg/lfg.o \
X+		$(SRCDIR)/lcg64/lcg64.o \
X+		$(SRCDIR)/pmlcg/pmlcg.o \
X+		$(SRCDIR)/mlfg/mlfg.o $(SRCDIR)/cmrg/cmrg.o \
X+		$(SPRNG_COMMON_DEPEND) $(GMPLIB)
X 
X sprng.o : $(SRCDIR)/interface.h sprng.c   $(SRCDIR)/memory.h  \
X 	$(SRCDIR)/multiply.h $(SRCDIR)/store.h $(SRCDIR)/fwrap_.h
52ba6067d48d96b989dbde185b8c32eb
echo x - files/patch-EXAMPLES_checkpoint-simple.c
sed 's/^X//' >files/patch-EXAMPLES_checkpoint-simple.c << 'ffd30d00b1e80c51d8c07c984c152a5a'
X--- EXAMPLES/checkpoint-simple.c	1999-06-29 18:42:03.000000000 +0200
X+++ EXAMPLES/checkpoint-simple.c	2011-01-16 11:41:48.000000000 +0100
X@@ -8,6 +8,7 @@
X /****************************************************************************/
X 
X 
X+#include <stdlib.h>
X #include <stdio.h>
X 
X #define SIMPLE_SPRNG		/* simple interface                         */
ffd30d00b1e80c51d8c07c984c152a5a
echo x - files/patch-EXAMPLES_pi-simple.c
sed 's/^X//' >files/patch-EXAMPLES_pi-simple.c << 'e34e8594876ca1569f1aa31faf496c4d'
X--- EXAMPLES/pi-simple.c	1999-06-29 18:42:03.000000000 +0200
X+++ EXAMPLES/pi-simple.c	2011-01-16 11:43:20.000000000 +0100
X@@ -6,6 +6,7 @@
X /***************************************************************************/
X 
X 
X+#include <stdlib.h>
X #include <stdio.h>
X #include <math.h>
X #include <string.h>
e34e8594876ca1569f1aa31faf496c4d
echo x - files/patch-EXAMPLES_spawn.c
sed 's/^X//' >files/patch-EXAMPLES_spawn.c << '69b157c2cc2ce6ad934e8b74fff921f7'
X--- EXAMPLES/spawn.c	1999-06-29 18:42:03.000000000 +0200
X+++ EXAMPLES/spawn.c	2011-01-16 11:44:47.000000000 +0100
X@@ -5,6 +5,7 @@
X /* is printed.                                                            */
X /***************************************************************************/
X 
X+#include <stdlib.h>
X #include <stdio.h>
X 
X /* Uncomment the following line to get the interface with pointer checking */
69b157c2cc2ce6ad934e8b74fff921f7
echo x - files/patch-TESTS_chisquare.c
sed 's/^X//' >files/patch-TESTS_chisquare.c << '2a516c58b026b369dedeb38ede81fdea'
X--- TESTS/chisquare.c	1999-06-29 18:42:11.000000000 +0200
X+++ TESTS/chisquare.c	2011-01-16 12:06:04.000000000 +0100
X@@ -2,7 +2,9 @@
X      Chi-Square Probability Function and Kolmogorv-Smirnov 
X **********************************************************/
X 
X+#include <stdlib.h>
X #include <stdio.h>
X+#include <string.h>
X #include <math.h>
X #include "util.h"
X 
2a516c58b026b369dedeb38ede81fdea
echo x - files/patch-TESTS_collisions.c
sed 's/^X//' >files/patch-TESTS_collisions.c << '7a0cce925605f37248523b79e8ba1fa9'
X--- TESTS/collisions.c	1999-06-29 18:42:11.000000000 +0200
X+++ TESTS/collisions.c	2011-01-16 12:09:10.000000000 +0100
X@@ -1,4 +1,6 @@
X+#include <stdlib.h>
X #include <stdio.h>
X+#include <string.h>
X #include "tests.h"
X #include <math.h>
X 
7a0cce925605f37248523b79e8ba1fa9
echo x - files/patch-TESTS_coupon.c
sed 's/^X//' >files/patch-TESTS_coupon.c << '199a78221c6a3faeccb5b4f07ceede66'
X--- TESTS/coupon.c	1999-06-29 18:42:11.000000000 +0200
X+++ TESTS/coupon.c	2011-01-16 12:10:34.000000000 +0100
X@@ -1,4 +1,6 @@
X+#include <stdlib.h>
X #include <stdio.h>
X+#include <string.h>
X #include "tests.h"
X 
X #ifndef ANSI_ARGS
199a78221c6a3faeccb5b4f07ceede66
echo x - files/patch-TESTS_maxt.c
sed 's/^X//' >files/patch-TESTS_maxt.c << '18073bc1568cc7eab353386094ddedde'
X--- TESTS/maxt.c	1999-06-29 18:42:11.000000000 +0200
X+++ TESTS/maxt.c	2011-01-16 11:48:38.000000000 +0100
X@@ -1,3 +1,4 @@
X+#include <stdlib.h>
X #include <stdio.h>
X #include "tests.h"
X #include <math.h>
18073bc1568cc7eab353386094ddedde
echo x - files/patch-TESTS_poker.c
sed 's/^X//' >files/patch-TESTS_poker.c << '3dc4be4b4d4587424d36052cbae0006c'
X--- TESTS/poker.c	1999-06-29 18:42:11.000000000 +0200
X+++ TESTS/poker.c	2011-01-16 12:11:22.000000000 +0100
X@@ -1,4 +1,6 @@
X+#include <stdlib.h>
X #include <stdio.h>
X+#include <string.h>
X #include "tests.h"
X #include <math.h>
X 
3dc4be4b4d4587424d36052cbae0006c
echo x - files/patch-TESTS_random__walk.c
sed 's/^X//' >files/patch-TESTS_random__walk.c << '2863b2ccf9289f9ac2ce851781b98a5c'
X--- TESTS/random_walk.c	1999-06-29 18:42:11.000000000 +0200
X+++ TESTS/random_walk.c	2011-01-16 11:50:16.000000000 +0100
X@@ -1,6 +1,7 @@
X /* A two-dimensional random walk test based on the code of I. Vattulainen, 
X    et al  */
X 
X+#include <stdlib.h>
X #include <stdio.h>
X #include "tests.h"
X #include <math.h>
2863b2ccf9289f9ac2ce851781b98a5c
echo x - files/patch-TESTS_sum.c
sed 's/^X//' >files/patch-TESTS_sum.c << '247fa2ea2d442d42abbba335981033d0'
X--- TESTS/sum.c	1999-06-29 18:42:11.000000000 +0200
X+++ TESTS/sum.c	2011-01-16 11:51:15.000000000 +0100
X@@ -1,6 +1,7 @@
X /*  Note: This test is not in the regular SPRNG test format */
X 
X 
X+#include <stdlib.h>
X #include <stdio.h>
X #if defined(SPRNG_MPI)
X #include "mpi.h"
247fa2ea2d442d42abbba335981033d0
echo x - files/patch-TESTS_init__tests.c
sed 's/^X//' >files/patch-TESTS_init__tests.c << '3aa39f7d92dd398d8f7027f00ab77fae'
X--- TESTS/init_tests.c	1999-06-29 18:42:11.000000000 +0200
X+++ TESTS/init_tests.c	2011-01-16 11:55:28.000000000 +0100
X@@ -1,6 +1,7 @@
X #ifdef SPRNG_MPI
X #include <mpi.h>
X #endif
X+#include <stdlib.h>
X #include <stdio.h>
X /*#define READ_FROM_STDIN*/   /* read random numbers from stdin */
X #ifndef READ_FROM_STDIN
3aa39f7d92dd398d8f7027f00ab77fae
echo x - files/patch-SRC_primes__32.c
sed 's/^X//' >files/patch-SRC_primes__32.c << 'cf2e5300418a95691f3791555c238c6e'
X--- SRC/primes_32.c~	1999-06-29 18:42:11.000000000 +0200
X+++ SRC/primes_32.c	2011-01-16 11:59:08.000000000 +0100
X@@ -1,5 +1,6 @@
X #include <stdio.h>
X #include <stdlib.h>
X+#include <string.h>
X #include "primes_32.h"
X #include "primelist_32.h"
X 
cf2e5300418a95691f3791555c238c6e
echo x - files/patch-SRC_primes__64.c
sed 's/^X//' >files/patch-SRC_primes__64.c << 'b5b4e3d381d3092d1adb11bc4e9bd2ee'
X--- SRC/primes_64.c	1999-06-29 18:42:11.000000000 +0200
X+++ SRC/primes_64.c	2011-01-16 12:01:30.000000000 +0100
X@@ -1,5 +1,6 @@
X #include <stdio.h>
X #include <stdlib.h>
X+#include <string.h>
X #include "primes_64.h"
X #include "primelist_64.h"
X 
b5b4e3d381d3092d1adb11bc4e9bd2ee
echo x - files/patch-EXAMPLES_checkpoint.c
sed 's/^X//' >files/patch-EXAMPLES_checkpoint.c << 'bd5b9135d4e37e3681661c8e379f1e5f'
X--- EXAMPLES/checkpoint.c	1999-06-29 18:42:03.000000000 +0200
X+++ EXAMPLES/checkpoint.c	2011-01-16 12:02:44.000000000 +0100
X@@ -8,6 +8,7 @@
X /****************************************************************************/
X 
X 
X+#include <stdlib.h>
X #include <stdio.h>
X 
X /* Uncomment the following line to get the interface with pointer checking  */
bd5b9135d4e37e3681661c8e379f1e5f
echo x - pkg-descr
sed 's/^X//' >pkg-descr << '7f9555c3c1089940396b503dd37f3979'
XComputational stochastic approaches (Monte Carlo methods) based on the random 
Xsampling are becoming extremely important research tools not only in their 
X"traditional" fields such as physics, chemistry or applied mathematics but also 
Xin social sciences and, recently, in various branches of industry.
XAn indication of importance is, for example, the fact that Monte Carlo
Xcalculations consume about one half of the supercomputer cycles. One of the
Xindispensable and important ingredients for reliable and statistically sound
Xcalculations is the source of pseudo random numbers. The goal of the project is
Xto develop, implement and test a scalable package for parallel pseudo random
Xnumber generation which will be easy to use on a variety of architectures,
Xespecially in large-scale parallel Monte Carlo applications.
X
XWhile SPRNG 4.0 is the newest version, this port only implements SPRNG 2.0, 
Xwhich is needed by some other parts of software like math/R.
X
XWWW: http://sprng.fsu.edu/Version2.0/
7f9555c3c1089940396b503dd37f3979
echo x - pkg-plist
sed 's/^X//' >pkg-plist << '842cde48cf18b70a11b15515ca566742'
Xbin/checksprng
Xbin/check.csprng
Xbin/check_sim.csprng
Xbin/check_ptr.csprng
Xbin/timesprng
Xbin/timingcsprng
Xinclude/sprng.h
Xinclude/sprng_f.h
Xinclude/interface.h
Xlib/libsprng.a
Xlib/libsprng.so
Xlib/libsprng.so.2
Xlib/libsprng.so.2.0
Xshare/sprng/gen0_lfg
Xshare/sprng/gen0_lfg.data
Xshare/sprng/gen1_lcg
Xshare/sprng/gen1_lcg.data
Xshare/sprng/gen2_lcg64
Xshare/sprng/gen2_lcg64.data
Xshare/sprng/gen3_cmrg
Xshare/sprng/gen3_cmrg.data
Xshare/sprng/gen4_mlfg
Xshare/sprng/gen4_mlfg.data
Xshare/sprng/gen5_pmlcg
Xshare/sprng/gen5_pmlcg.data
Xshare/sprng/new_sprng.ps
X at dirrm share/sprng
842cde48cf18b70a11b15515ca566742
echo x - pkg-message
sed 's/^X//' >pkg-message << '90c81c06929c43140502a9f17b449376'
X*******************************************************************************
X
XThe SPRNG libraries of generators produce good quality random numbers,
Xand are also fast. They have been subjected to some of the largest
Xrandom number tests.
X
XLanguages: C, C++, FORTRAN
X
XPlatforms: Cray T3E, IBM SP2, SGI Power Challenge Array, Origin 2000,
X           CONVEX Exemplar, SUN workstations, Intel, HP workstations ...
X
XGenerators: Modified Additive Lagged Fibonacci, Multiplicative Lagged
X            Fibonacci, Combined Multiple Recursive generator, three types of
X            Linear Congruential. 
X
XSPRNG version 2.0b is an old library from 1999 with only a few changes in 2007.
XThere is a newer version 4.0 (from 2007) with many changes on the API. For
Xdifferent reasons version 2.0 is needed from other stuff like multiprocessing 
Xwith math/R (package rsprng ...).
X
XThe installed library can be testet with 'checksprng' and 'timesprng'. They are
Xusing some testing data sets under /usr/local/share/sprng.
X
XDocumentation can be found under /usr/local/share/sprng/new_sprng.ps.
X
X*******************************************************************************
90c81c06929c43140502a9f17b449376
exit



More information about the freebsd-ports mailing list