[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: number of processors
From: |
Ralf Corsepius |
Subject: |
Re: number of processors |
Date: |
03 Sep 2002 12:05:41 +0200 |
Am Die, 2002-09-03 um 09.33 schrieb Philipp Gortan:
>
> # here comes your program...
> # after successful checking for proc' count, save nrprocs to file:
>
> FILE * fd;
> fd = fopen("./conftest.nrproc", "w");
> if(!fd) {
> exit(EXIT_FAILURE);
> }
> fprintf(fd, "%ld", nprocs);
> fclose(fd);
>
> # let your program end, here comes autoconf again
>
> ], [PROC_NR=`cat conftest.nrproc`], [PROC_NR=1])
>
> AC_SUBST([MAKE], ["make -j $PROC_NR"])
>
> AC_MSG_RESULT([$PROC_NR])
>
> </code>
Some remarks on your code:
* You know how to write to stdout, to catch the returned string and to
put it into a shell variable instead of writing into an external file?
* Your test doesn't consider cross-compilation.
* $MAKE is not always "make", so using "make -j" is wrong.
But, I think automatically setting make to run parallel is a highly
questionable feature. Actually, I think neither autoconf nor a package's
configuration is legitimated to do so in general at all.
It is the person who is about to run configure, to decide about it and
nobody else, because he is the only one who knows which resources shall
be allocated to the number of processes
(To exaggerate it: "Who are you to decide to block the department's
valuable XX processor-machine").
I.e. instead of trying to detect the number of processes, I'd recommend
to tell users to run
make -j <what-the-user-wants>
Ralf