From b70945de51cdfbec31a3cce4382c7f41cdb4895c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 27 Sep 2008 16:02:47 +0100 Subject: [PATCH] add nprocessors utility --- Makefile | 3 +++ nprocessors.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 nprocessors.c diff --git a/Makefile b/Makefile index b41c543..d3ddd4f 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ minimise: energy.o graph.o common.o mgraph.o minimise.o half.o primer: primer.o common.o $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) +nprocessors: nprocessors.o common.o + $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) + prime.data: primer ./$^ $o diff --git a/nprocessors.c b/nprocessors.c new file mode 100644 index 0000000..b15bf8e --- /dev/null +++ b/nprocessors.c @@ -0,0 +1,16 @@ +/* + * prints number of processors + */ + +#include + +#include "common.h" + +int main(int argc, char **argv) { + if (argc!=1) fail("usage: nprocessors\n"); + long sc= sysconf(_SC_NPROCESSORS_ONLN); + if (sc==-1) diee("nprocessors: sysconf failed"); + printf("%ld\n",sc); + flushoutput(); + return 0; +} -- 2.30.2