Thanks a lot Javier. That is very helpful.
On Tue, Apr 13, 2010 at 4:26 PM, Javier Merino <merinocj@xxxxxxxxx> wrote:
I usually spawn the processes and then processor_bind() them. Like:
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <sys/processor.h>
#include <sys/procset.h>
static void exec_and_bind(char **argv, int proc_num) {
pid_t child_pid = fork();
if (child_pid)
processor_bind(P_PID, child_pid, proc_num, NULL);
else
execv(argv[0], argv);
}
int main(void) {
char *b1[3];
char *b2[4];
b1[0] = strdup("/path/to/bench1");
b1[1] = strdup("arg1");
b1[2] = NULL;
b2[0] = strdup("/path/to/benchmark2");
b2[1] = strdup("arg1");
b2[2] = strdup("arg2");
b2[3] = NULL;
exec_and_bind(b1, 0);
exec_and_bind(b2, 1);
return 0;
}
Hope this helps,
Javi
Dan Gibson wrote:
> It takes a brilliant man to detect typos.
>
> I'm not sure that processor_bind() can be used by a non-parent process
> -- try having each process processor_bind() itself.
>
> Also, check the return codes of processor_bind() to see if it is
> successful or not.
>
> Regards,
> Dan
>
> On Tue, Apr 13, 2010 at 3:05 PM, sparsh mittal ISU < sparsh@xxxxxxxxxxx
> <mailto: sparsh@xxxxxxxxxxx>> wrote:
>
> Thanks for the remark. Yes,that was a typo. (you are really
> brilliant Dan). I corrected it and tried again. However the output
> of prstat -a is
> PID state cpu process
> 316 cpu0 50% app1
> 317 run 50% app2
> 324 cpu1 0.1% prstat
>
> Thus, on cpu1, prstat is running, so, that may be the reason that
> app2 is put on the run queue. The man prstat shows that cpu
> utilization shows: "The percentage of recent CPU time used by the
> process." That means 50% of time of cpu0 is being used by app1.
> But why not 100%?
>
> Thanks
> Sparsh
> On Tue, Apr 13, 2010 at 2:15 PM, Dan Gibson < degibson@xxxxxxxx
> <mailto: degibson@xxxxxxxx>> wrote:
>
> It looks like you are binding both to processor 0. Was that a typo?
>
>
> On Tue, Apr 13, 2010 at 2:13 PM, sparsh mittal ISU
> < sparsh@xxxxxxxxxxx <mailto: sparsh@xxxxxxxxxxx>> wrote:
>
> Hello
> Thanks for the responses.
> I think the number of processors should be power of two. So,
> if I try to use processor_bind, then I have tried the
> following program.
>
> #include<sys/types.h>
> #include <sys/processor.h>
> #include <sys/procset.h>
>
> int main()
> {
> processor_bind(272, 316, 0,NULL);
> processor_bind(272, 317, 0, NULL);
> return 0;
> }
>
> Here 316 and 317 are the PIDs of two benchmarks and 272 is
> the PPID, as shown by command ps -el.
> So, I compiled the program, by
> gcc process.c -o procExe
>
> and then I execute it
> ./procExe
>
> Is that all? I still see the CPU utilizations to be around
> 50% and never two processes are simultaneously running.
> Thanks
> Sparsh
>
>
> On Tue, Apr 13, 2010 at 1:33 PM, Dan Gibson
> < degibson@xxxxxxxx <mailto: degibson@xxxxxxxx>> wrote:
>
> I don't know the details, but somehow psrset_bind is
> stronger than processor_bind, though the latter allows
> 'binding' to processor zero. I would call processor_bind().
>
> Regards,
> Dan
>
> 2010/4/13 Javi Merino < merinocj@xxxxxxxxx
> <mailto:merinocj@xxxxxxxxx>>
>
> Dan Gibson wrote:
> > >From man psrset:
> > The default processor set (0) always exists and
> may not be destroyed.
> > All processes and processors at system init time
> start out in the
> > system default processor set. For this reason
> processor 0 may never be
> > removed from the default group. (Hence this
> feature is of no value on
> > a single processor system.)
> >
> > Hence, in order to have two bound processes, you
> need at least three
> > processors. What you have probably done is
> inadvertently bound both
> > processes to CPU 1.
>
> What I do is launch the benchmarks and then run a C
> program which
> basically does:
>
> processor_bind(P_PID, pid_of_bench1, 0, NULL);
> processor_bind(P_PID, pid_of_bench2, 1, NULL);
>
> I think this way you avoid the processor sets. I did
> this a while ago
> and can't remember the details, but I think this
> works and effectively
> binds the pids to processors 0 and 1. Is it wrong?
>
> Regards,
> Javi
>
> _______________________________________________
> Gems-users mailing list
> Gems-users@xxxxxxxxxxx <mailto:Gems-users@xxxxxxxxxxx>
> <http://www.cs.wisc.edu/%7Egibson> [esc]:wq!
>
> _______________________________________________
> Gems-users mailing list
> Gems-users@xxxxxxxxxxx <mailto:Gems-users@xxxxxxxxxxx>
> Gems-users@xxxxxxxxxxx <mailto:Gems-users@xxxxxxxxxxx>
> <http://www.cs.wisc.edu/%7Egibson> [esc]:wq!
>
> _______________________________________________
> Gems-users mailing list
> Gems-users@xxxxxxxxxxx <mailto:Gems-users@xxxxxxxxxxx>
> Gems-users@xxxxxxxxxxx <mailto:Gems-users@xxxxxxxxxxx>
_______________________________________________
Gems-users mailing list
Gems-users@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/gems-users
Use Google to search the GEMS Users mailing list by adding "site:https://lists.cs.wisc.edu/archive/gems-users/" to your search.
-- Thanks and Regards Sparsh Mittal Graduate Student Electrical and Computer Engineering Iowa State University, Iowa, USA
|