Hi Chapel users!
Several of you have asked about the expected behavior for chdir() and
cwd() in a multi-locale or multi-task context. While Chapel's current
behavior for these functions matches that of the C implementation that
we wrap, we decided that perhaps this approach could be too confusing
w.r.t. other aspects of Chapel's global-view programming module so some
clarifying changes were in order.
To summarize: right now the current working directory is unique to any
given locale, such that a chdir() on locale 0 will leave the current
working directory (cwd) of locales 1 through n unchanged; within a
locale all tasks share a common cwd, such that a chdir() on a given task
will affect the cwd for all other tasks on that locale. For example,
see the behavior of the following code in a multi-locale context:
chdir("/tmp");
coforall loc in Locales {
on loc {
var datfile = open("loc" + here.id + ".dat");
...
// one might expect all files to be stored at /tmp/loc<i>.dat,
// but since the chdir() only executed on locale #0, all other
// locales will open the file in the cwd that they had at
// program startup.
}
}
While this behavior is not necessarily bad, it may be unexpected. There
is no obvious link between a locale and its current working directory,
and having changes to it only affect whatever locale you happen to be on
at the time is confusing. Approaching from another direction, it may
not be entirely obvious that altering the cwd of one task will affect
other tasks that access that locale - one would not necessarily think
that altering the directory in a parallel context constitutes a data
race, though it becomes apparent upon reflection.
The Proposal:
To alleviate this confusion without adding undue overhead, we would like
to make chdir() and cwd() methods on a particular locale. For instance,
one would have to specify:
here.chdir("foo/"); // to change the current locale's cwd
here.cwd(); // to see the current locale's cwd
Locales[1].chdir("bar/"); // to change locale 1's cwd
Locales.chdir("bar/"); // to change the cwd for all locales
This has the benefit of making the effects of this call immediately
obvious - the current working directory is now considered part of the
state of a given locale. To affect any other locales, the call must be
made on them as well. And since tasks are confined within a single
locale unless a different locale is specified during their execution, it
is obvious that changes made to the current locale's cwd will affect all
other tasks operating on that locale. It is also obvious that entering
a different locale will result in a different cwd. The previous
implementation of chdir() and cwd() can be reused almost trivially.
While we considered several other paths forward, we feel this is far and
away the best course forward. What do you think? We'd like to hear any
thoughts and concerns you might have.
On behalf of the Chapel team, thank you for your attention and input!
Lydia Duncan
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users