►
From YouTube: 04 - Programming Environment and Compilation
Description
Part of the NERSC New User Training on September 28, 2022.
Please see https://www.nersc.gov/users/training/events/new-user-training-sept2022/ for the training day agenda and presentation slides.
A
A
A
So
the
first
thing
I'm
going
to
start
with
is
modules
modules
is
like
your
first.
The
first
way
you're
going
to
be
interacting
with
software
installed
and
pearl
Metter
I've
got
this
slide,
which
is
going
to
tell
you
sort
of
most
of
what
you
need
to
know
about
it
right.
So
at
the
very
top
this
slide.
This
is
sort
of
like
what
you
see
when
you
log
in
this
is
your
prompt.
A
If
you
were
suppose
you
know,
you're
just
checking
out
the
version
of
python
I,
just
type
here,
python
version-
and
you
see
it's
Python
2.7
well,
for
example,
python3
is
already
installed
on
Pearl
Mudder.
All
we
need
to
do
is
load
the
right
module
that
has
python3
that
makes
Python
3
available
to
me.
So
what
we
see
on
my
next
line
here
is
module
list.
This
shows
the
modules
that
were
currently
loaded.
A
It
doesn't
include
the
python
module
that
contains
python3.
That's
why,
when
I
type
the
python
version
I
got
2.7
when
I
typed
module
load
python,
that
loaded
the
the
module
of
python,
that
has
version
3.9,
and
you
see
that
when
I
type
the
module
list
so
now,
when
I
check
the
python
version,
this
meaning
makes
python
version
3.9
available
to
meet
in
my
user
environment.
So
so
modules
are
the
way
we
sort
of
manage
all
the
different
software
packages
that
are
available
on
Pearl
Mudder,
because
you
know,
if
they've,
all
loaded.
A
At
the
same
time,
it
could
cause
all
sorts
of
problems.
So
this
is
the
way
you
load
one.
At
a
time
we
have
a
long
list
of
modules
and
and
software
we
have
chemistry
packages.
We
have
Material
Science
packages
that
are
available
as
modules.
So
this
is
you
know.
If,
if
you
need
to
use
one
of
them,
you
know
module
load
there.
A
These
are
the
modules
that
are
loaded
by
default.
I'll
point
out
a
few
of
them.
The
first
one
here
is
the
gray
P
x86
Milan,
this
sort
of
defines
the
CPU
architecture.
A
So
we'll
talk
more
about
compiling
later,
but
this
allows
to
create
wrappers
to
really
focus
the
compilation
code
on
the
the
CPU
architecture
and
get
more
speed
out
of
it.
That
way,
there's
two
other
modules
I
want
to
point
out
here.
This
is
the
program
environment,
gnu
and
the
gcca
compiler.
These
are
the
default
programming,
environment
and
compiler
that
you
see
when
you
log
in
and
then
there's
some
other
settings
here.
The
ones
in
green
relate
to
gpus.
A
So
if
you're
compiling
for
gpus
the
Craig
compiler
wrappers
will
use
the
details
in
this
module
to
optimize
for
that
and
another
one
to
point
out
here,
that's
loaded
by
default
is
this
GPU
module,
which
will
also
load
the
GPU
toolkit
for
you
and
by
deep
in
this
one
we'll
set
you
to
aware
MPI,
which
we'll
talk
a
little
bit
more
about
later
on
this
slide,
I
have
sort
of
your
most
common
commands
that
you'll
use
when
you're
using
modules.
A
The
thing
to
point
out
is
because
a
lot
of
people
I
think
are
coming
from
Corey
and
looking
at
Pearl
miter
is
we're
using
a
slightly
different
module
system.
Now
it's
lmod,
and
so
some
of
these
commands
might
behave
a
little
bit
differently
and
some
of
them
are
are
just
different,
so
module
list.
That
shows
you
all
the
modules
that
are
currently
loaded
in
your
user
environment,
like
you,
saw
on
the
previous
slide.
A
May
you
load
and
unload
those
is
as
before,
with
module
load
and
unload
module
swap
will
still
work.
If
you
want
to
do
that,
all
in
one
step
take
one
out
and
put
one
back
in.
A
That's
that
covers
kind
of
most
of
what
you'll
end
up
doing
when
you
want
to
start
seeing
more
details
about,
what's
going
on,
modules,
show
will
show
you
how
each
module
is
changing
your
user
environment,
which
can
be
really
helpful
for
sort
of
understanding.
What's
going
on
when
you
load
and
unload
modules
and
module
spider
is
kind
of
the
new
way
to
find
the
module
you
want,
or
a
software
package
that
you're
looking
for
on
parameters.
So
I'll
give
you
a
specific
example
about
that
in
the
next
slide.
A
I
want
to
point
out
some
kind
of
neat
tricks
that
you
might
find
useful
if
you
want
to
pipe
output
from
module,
it's
helpful
to
use
the
redirect
flag
and
in
this
sort
of
line,
what
I'm
doing
is
I'm
piping,
the
output
from
module,
but
the
out
the
the
command
I'm
running
is
spider,
but
the
dash
R
flag
tells
it
to
look
for
regular
Expressions,
so
I'm,
basically
outputting
every
possible
package
and
I'm
gripping
through
that
for
the
for
a
particular
string,
because
I
might
be
looking
for
a
pretty
good
thing,
and
this
could
help
me
find
it.
A
This
ml
is
a
shortcut
for
module
list
and
the
dash
T
will
put
it
down
in
a
list.
So
earlier
schizab
mentioned
like
when
you
file
a
ticket.
Sometimes
it
can
be
helpful
to
show
which
modules
you
have
loaded.
A
Ml-T
puts
that
in
a
nice
vertical
list
to
just
copy
and
paste
module
reset
will
bring
you
back
to
the
default
set
of
modules
that
you
get
when
you
log
on,
but
that
one
should
be
available
after
the
next
promoter.
Maintenance,
so
in
this
next
slide
we
I'm
going
to
show
you
why
we
no
longer
recommend
you
doing
module
available
and
and
recommend
that
you
use
module
spider
instead
and
essentially,
what
this
comes
down
to
is
not.
A
You
may
not
see
every
single
package
when
you
type
module
available
Avail,
because
you
know
lmod
has
this
hierarchical
module
system.
So
in
this
example,
what
we're
going
to
do
is
we're
going
to
try
to
module
load,
cray,
Dash
netcdf,
and
what
you'll
see
is
it's
not
loaded
here,
but
when
we
take
module
I'll,
let
it
go.
We
can't
just
we
weren't
able
to
pull
it
up
just
like
this,
and
it
doesn't
show
up
the
module
show
either.
A
However,
if
I
use
module
spider
for
the
package
I
want,
it
shows
up
so
here
to
get
more
information
about
the
package.
I
give
it
the
package
and
the
version
number
the
same:
Command,
Module
spider,
and
now
it
tells
me
oh
to
get
the
one
I
want.
I
actually
have
to
load
cray
Dash
hdf5
first.
A
A
This
is
a
like:
what's
going
on
scenes
when
you
do
a
module
load,
so
this
is
what
the
Command
Module
show
does
for
you.
It
tells
you
what
are
those
commands
that
are
being
run?
That's
essentially
changing
your
user
environment
to
make
the
the
software
available
the
software
that
you
want
available
to
you
in
your
environment,
so
I
I've,
just
sort
of
roughly
split
this
up
into
like
three
separate
pieces.
A
You
know
the
piece
isn't
highlighted
in
red
are
sort
of
extra
information
about
names
and
info,
but
the
ones
in
yellow
are
changes
to
your
path.
You
know
so
the
way
Linux
works
is
when
it
looks
to
run
a
software
or
an
executable.
It's
looking
for
it
in
your
path.
So
by
changing
or
adding
file
locations
to
your
path,
it
makes
more
executable
files
available
to
you
so
that
you
can
run
them
on
Perl
meters.
A
Obviously,
there's
there's
more
than
one
path
here,
because
the
environmental,
the
user
environment
and
promoters
complicated
the
other
things
that
a
module
show
command
will
do
is
it'll
make
it'll
set
other
environmental
variables
like,
for
example,
this
hdf5
dir,
that's
important
for
when
you're
like
compiling
a
code
that
depends
on
hdf5,
so
that
other
code,
sorry
that
other
code,
if
you're,
if
you're
building
a
system-
and
you
say
like
okay,
I-
have
hdf5,
and
it's
going
to
look
for
that-
find
my
mental
variable
hdf5.dir
to
know
how
to
link
it
back
to
the
other
one.
A
So
all
of
this
kind
of
happens
behind
the
scenes
when
you
type
module
load
and
module
unload
and
modules
show
give
makes
all
those
details
apparent
in
case.
You
need
to
go
in
and
figure
out
exactly
what's
happening,
but
in
general
module
load
and
unloaded
will
do
what
you
want.
Most
of
the
time.
A
So
now
that
we
have
an
incentive
about
modules-
probably
the
most
important
thing
you'll
want
to
use
them,
for
is
configuring
the
programming
environment.
A
So
we
have
I,
wouldn't
say
we
have
more
than
three
but
I'm
going
to
focus
on
three
main
programming
environments
on
Pearl
Mudder,
that's
essentially
the
the
new
programming
environment.
That's
the
default,
the
Nvidia
programming
environment,
which
is
essentially
what
I
would
recommend
you
you
work
on.
If
you
want
to
compile
for
gpus
and
the
create
programming
environment,
which
you
know,
if
you
want
to
sort
of
squeeze
out
the
maximum
performance
of
the
system,
this
one
might
be
something
you
would
try.
A
What
you
see
in
this
chart
is
the
compiler
used
in
each
programming
environment,
right
for
C,
plus,
plus
it's
D
plus
plus
for
C
and
CT
G
for
Fortran,
g4train
and
so
on.
Right,
we're
gonna,
talk
about
and
I'll
focus
a
little
bit
more
on
is
cray
provides
wrappers
for
these
compilers
so
that
when
you're
in
the
program,
environment,
canoe
instead
of
saying
G
plus
plus,
you
can
type
CC
and
the
system
will
automatically
know
because
I
have
this
programming
environment
loaded.
A
That
I
want
to
use
the
G
plus
plus
compiler,
and
it
will
do
actually
a
lot
more
for
you,
so
these
sort
of
programming
environments
work
in
conjunction
with
these
wrappers
to
do
a
lot
of
optimizations
in
the
compile
step.
A
One
other
thing
I
want
to
point
out
is
that
MPI
is,
you
know,
is
kind
of
taken
care
of
automatically
under
the
covers
when
using
these
wrappers,
and
it's
this
crate
in
Pitch
that
that
goes
along
with
each
one
of
these
programming
environments.
A
A
A
So
I
said
I
would
talk
about
the
compiler,
wrappers
and
sort
of
what's
going
on
behind
the
scenes
when
you're
using
them.
So
this
is
what
this
slide
is
trying
to
show.
A
What
I
have
here
is
one
line
where
I
compiled
sort
of
just
my
basic
C
code
with
GCC
and
instead
of
doing
GCC,
I'm
I'm
in
the
the
new
programming
environment
and
I'm,
using
the
CC
Craig
compiler
wrapper
instead,
and
what
I've
done
here
is
I've
added
the
create
PE
verbose
command,
which
will
show
kind
of,
like
all
the
extra
commands
that
are
being
hidden
behind
this
wrapper
here
when
I
when
I
run
this
compile
line.
So
essentially,
what
this
is
saying
is
that
CC
helloworld.c
Etc
is
the
same
as
typing
GCC.
A
You
know,
Dash
M
Arch
equals
the
end
version
and
so
on
and
so
on
and
so
on
and
so
on
and
so
on,
and
so
and
so
on,
whereas
if
you
just
type
GCC
you're
going
to
lose
all
these
sort
of
optimizations
and
automatic
links
and
such
and
so
on,
some
other
things
to
point
out
that
are
being
happening
when
you
use
the
CC
wrapper.
A
Is
it's
automatically
including
MPI
through
mpitch
here,
and
it's
also
the
MPI
that's
compiled
with
the
compiler
in
that
programming
environment,
such
as
gnu
same
thing
for
the
science
libraries
which
I'll
mention
another
for
another
slide,
that's
automatically
all
being
taken
care
of
inside
this
CCC
wrapper.
So
we
really
recommend
that,
when
you're
compiling
your
code
on
promoter
that
you
you
give
the
wrappers
a
shot
in
the
next
slide,
you
have
the
whole
complete
list
of
the
output
of
this.
A
Like
sort
of
simple
example,
you
can
see,
we've
got
it's
linking
you've
got
the
automatically
you've
got
the
Linker
flags
up
here.
You've
got
the
path
to
the
libraries
automatically
included,
and
you
know
a
ton
of
things
essentially,
some
of
which
will
allow
your
code
to
be
further
optimized
by
the
compiler,
so
it
will
run
faster.
A
A
Again,
just
to
sort
of
belabor
the
point
of
all
the
stuff,
that's
done
automatically
by
the
wrapper,
if
you're
using
the
great
compiler
wrappers,
you
know
it's
going
to
include
the
MPI.
A
The
scientific
packages
like
low
pack,
blast,
Scala
pack
and
more
they're,
all
going
to
be
included
automatically
you
don't
even
have
to
you
know,
include
the
the
dash
L
lines,
the
Linker
lines,
if
you're
have
loaded
specific
modules
such
as
hdf5
or
fftw,
those
will
also
be
automatically
included
if
you're
you're,
using
the
the
create
compiler
wrappers,
so
they're
really
there
to
to
facilitate
a
lot
of
use
and
make
things
easier
for
you
as
a
user.
A
A
So
if
you
want
to
know
more
information
about
them,
the
man
page
to
read
all
about
that
and
the
way
that's
packaged
in
the
tray
on
a
cray
system
is,
is
here.
Okay,.
A
What
I
want
you
to
know
from
this
slide
is
that
Cuda
aware
MPI
is
enabled
by
default
before
I,
but
before
I
keep
moving.
I
should
tell
you
what
that
is
so
so
what
is
computer
aware
MPI?
Well,
MPI?
Is
you
know
when
we're
familiar
with
MPI
from
Corey
right?
This
is
a
way
for
processes
to
talk
to
each
other
CPUs,
to
exchange
information
between
each
other
to
do
large,
computations
and
distribute
that
work
among
each
other,
but
that's
kind
of
from
before
GPU
times.
A
So
the
next
step,
to
sort
of
when
you
now,
when
you
have
a
GPU
attached
to
this
right,
like
you,
could
have
MBI,
but
it's
still
talking
from
TPU
to
CPU,
and
then
you
know
if
it
needs
to
add
a
GPU
on
the
end
it
has
to
go
GPU
to
CPU.
Then
I
send
my
MPI
message
to
the
other
CPU
to
another
GPU
right
and
so
with
Cuda.
A
Where
MPI
you,
don't
you
no
longer
have
to
go
through
the
CPU,
the
gpus
can
actually
directly
pass
those
messages
to
each
other,
so
it
makes
certain
workflows
a
certain
codes.
You
know
you
might
get
a
large
speed
up
from
the
way
that
those
messages
are
being
passed
from
device
to
device
you
know.
A
So
how
do
you
enable
aware
MPI,
you
load
the
GPU
module
inside
if
I
do
module
show
on
GPU?
It
shows
that
it's
turning
this
environmental
flag
on
this
in
Pitch
TPU
support,
enabled
if
you
want
to
turn
it
off,
you
can
do
module
load
CPU
and
if
you
did
module
showed
CPU,
it
would
show
you
that
it
would
set
this
environment
mpitch
GPU
support
enabled
to
zero.
So
that's!
What's
going
on
behind
the
scenes
with
that
flag
foreign,
furthermore,
about
compiling.
A
You
know
so,
if
you're
dealing
with
a
a
make
system,
such
as
cmake
or
you're,
doing
the
the
normal
sort
of
configure
make
make
install,
you
may
have
to
make
some
adjustments
to
use
the
compiler
Flags.
This
is
the
line
I
have
here.
So
one
way
to
do
this
is
to
set.
This
is
essentially
setting
this
environment,
the
CC
environment,
variable
to
the
CT,
that's
provided
by
the
create
programming,
environment
and
and
so
on,
or
if
you're
doing
this
with
a
configure
step.
A
It
would
look
like
this
I'm
totally
blanking
on
time
and
how
I'm
doing
sorry
Helen
10
more
minutes.
Okay,
10,
more
minutes.
A
A
A
Well
they're
good
to
know
compiler
settings.
The
only
one
I
really
want
to
point
out
here
is
that
openmp
is
not
enabled
by
default
again.
I
believe
this
is
a
difference
from
Corey.
But
if
you
want
openmp
to
to
run
you,
you
need
to
add
the
flags
and
the
flag
differs
depending
on
which
compiler
and
you
know
which
programming
environment,
you're
you're
using.
A
A
A
A
So
what
I'm
showing
is
that's
the
code
that
I
have
from
that
previous
example?
These
are
the
modules
I
have
loaded
in
this
example,
I'm
I'm
running
only
on
the
CPU,
so
I'm
only
compiling
my
code
to
have
it
run
on
the
CPU.
A
The
only
thing
the
other
thing
I
want
to
say
about
this
is
if
you're
coming
from
Corey,
especially
like
where
you
have
code
that
only
runs
on
CPUs
and
it's
multi-threaded
to
take
advantage
of
openmp
openmp.
This
is
like
the
example
that
you
would
use
to
focus
on
so
that
when
you
switch
to
promoter,
this
is
how
you
would
compile
your
code
to
run
only
on
CPUs
once
again
in
the
next
example.
This
does
sort
of
one
step
more
right.
A
It
takes
that
same
code
and
then,
instead
of
running
the
multi-threaded
application
on
the
CPU,
it
offloads
that
work
to
run
multi-threaded
on
the
GPU.
The
only
difference
in
this
setup
here
is
I'll
walk
through
the
Cisco,
so
I've
got
the
same
code,
I'm
listing
the
modules.
What
I
want
to
point
out
here
is
I,
have
the
Nvidia
programming,
environment,
loaded
and
I?
Have
the
GPU
module
loaded,
and
so
with
those
modules
I
can
let
the
cray
wrappers
kind
of
take
care
of
everything
else.
A
I
use
this
line.
Dash
MP
equals
GPU
that
tells
it
to
do
the
openmp
threads
on
the
GPU,
the
mfo
command.
That's
what
which
you
see
up
there
from
after
the
main.
It
shows
you
what
part
of
the
code
it
changed.
It
change
the
GPU
code
to
run
on
the
GPU,
and
you
see
the
same
result
if
you're
running
with
Ace
open
ACC,
it's
you
know
a
very
similar.
A
A
So
what
we
have
here
is
you
know
similar
things
to
point
out,
because
I'm
compiling
code
for
the
GPU
I
want
to
be
in
the
programming
Enviro,
the
Nvidia
programming
environment
I
want
to
have
the
GPU
module
loaded,
and
this
is
just
to
reiterate
what
we
covered
earlier
is
that
the
mph
TPU
support
enabled
flag
is
what
allows
which
turns
the
Cuda
aware,
NPI
on
and
off.
A
A
But
but
essentially,
what
you're
seeing
is
with
the
create
compiler
wrappers,
the
the
command
capacities
codes
is
fairly
straightforward.
A
A
I'll,
let
it
I'll
let
it
run
so
in
this
example,
essentially,
we
have
a
code
that
depends
on
the
hyper
package
and
I
installed
this,
for
this
example,
I've
already
installed
it
manually
in
a
different
location.
A
A
A
And
then,
if
we
let
this
go,
you'll
you'll
see
that
it
turns
out.
It
worked.
So,
okay,
so
I
hope.
Those
examples
are
helpful,
but
obviously
compiling
can
be
much
more
complex,
depending
on
your
exact,
specific
use
case.
So
I
leave
these
additional
Resources
with
you.
A
The
other
thing
to
mention
is
the
llvm
programming
environment
is
also
available
on
Pro
matter.
At
this
point,
it's
still
experimental.
So
if
you
want
to
load
it,
you
have
to
do
this
first
step.
Is
you
have
to
do
this
module
use
to
this
location,
then
module
load,
MPE,
and
then
you
can
get
into
this
llvm
programming,
environment,
foreign.
A
So
the
next
thing
I
want
to
talk
about
quickly.
Is
shell
Scripts?
So
why
do
we
want
a
shell
script?
Well
suppose,
every
time
you
log
on
you
type
the
same
four
lines
to
get
into.
You
know
you
want
your
python.
You
want
to
go
to
the
create
program
environment.
You
want
to
set
some
specific
environmental
variables.
Well,
if
you're,
tired
of
typing
out
of
that
every
single
time,
what
would
you
do
right?
Well,
you
could
take
it
and
put
it
into
a
script.
A
Where
would
you
put
this
script?
Well,
all
the
Consultants
are
probably
going
to
overwhelmingly
recommend
that
you
put
it
in
its
own
separate
file
so,
for
example,
config
my
environment.sh,
and
that
every
time
you
want
to
run
these
commands,
you
can
just
Source
this
file.
We
definitely
recommend
this
over
putting
in
places
like
bashrc
or
bash
profile
or
someplace
like
that.
Just
because
having
it
automatically
loaded
can
sort
of
lead
to
unexpected
results,
and
it's
easy
to
forget.
A
A
So
the
only
the
in
the
last
section
here
I
want
to
talk
a
little
bit
about
spec
is
back,
is
sort
of
another
source
of
software
available
on
promoter.
You
can
see,
there's
a
again
two
spec
locations.
One
is
the
e4s
software
stack
that
has
319
packages
back
packages.
The
other
one
is
the
sort
of
vanillus
back,
which
has
130
packages.
A
There's
quite
a
bit
of
software.
Here,
that's
already
been
pre-installed
that
you
can
use
Mac
to
to
load
into
your
environment,
or
if
you
want
something
that
has
a
spec
package.
That's
not
here,
you
can
use
it.
You
can
install
it
yourself.
So
that's
where
you
get
these
two
columns
on
the
left.
This
is
how
you,
you
know,
load
a
package
that
is
already
pre-installed
on
the
right
is.
A
If
you
found
one
of
these
packages,
you
found
the
package,
you
don't
the
package,
you
want,
isn't
actually
already
installed,
but
it
does
there's
this
backpack
available
for
it.
You
would
follow
down
this
column.
A
This
example
shows
you
how
to
use
a
SPAC
installed
package
as
a
dependency
to
compile
something
and-
and
this
is
going
to
be
my
last
slide.
But
my
key
suggestions
to
remember
from
today
are
module.
Spider
is
what
you
want
to
use
from
now
on.
A
The
compiler,
the
created
compiler,
wrappers,
Capital,
CC,
CC
and
FTM
for
Fortran
are
going
to
add
a
lot
of
convenience
and
do
a
lot
of
optimizations
for
you
there's
more
software
available
through
this
back
in
e4s
modules,
and
if
you
want
to
modify
your
environment
on
a
regular
basis,
please
write
a
script
that
you
can
Source
each
time
so
with
that
I
will
end.