Next: Linking/Windows, Previous: BestLibrary, Up: General
ACML Home page | ACML forum | Knowledge base | Email Feedback
If the Linux 64-bit gfortran version of ACML was installed in the default directory, /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64, then the command:
gfortran -m64 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib -lacml
can be used to compile the program driver.f and link it to the ACML.
The ACML Library is supplied in both static and shareable versions, libacml.a and libacml.so, respectively. By default, the commands given above will link to the shareable version of the library, libacml.so, if that exists in the directory specified. Linking with the static library can be forced either by using the compiler flag -static, e.g.
gfortran -m64 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib -static -lacml -lrt
or by inserting the name of the static library explicitly in the command line, e.g.
gfortran -m64 driver.f /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib/libacml.a -lrt
Notice that if the application program has been linked to the shareable ACML Library, then before running the program, the environment variable LD_LIBRARY_PATH must be set. Assuming that libacml.so was installed in the directory /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib, then LD_LIBRARY_PATH may be set by, for example, the C-shell command
setenv LD_LIBRARY_PATH /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib
(See the man page for ld(1) for more information about LD_LIBRARY_PATH.)
The command
gfortran -m32 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran32/lib -lacml
will compile and link a 32-bit program with a 32-bit ACML.
If you have an SMP machine and want to take best advantage of it, link against the gfortran OpenMP version of ACML like this:
gfortran -fopenmp -m64 driver.f
-L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64_mp/lib -lacml_mp
gfortran -fopenmp -m32 driver.f
-L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran32_mp/lib -lacml_mp
Note that the directories and library names involved now include the suffix _mp.
To compile and link a 64-bit C program with a 64-bit ACML, invoke
gcc -m64 -I/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/include driver.c
-L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib -lacml -lgfortran
The switch "-I/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/include" tells the compiler to search the directory /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/include for the ACML C header file acml.h, which should be included by driver.c. Note that it is necessary to add the gfortran compiler run-time library -lgfortran when linking the program.
Similar commands apply for the PGI versions of ACML. For example,
pgf77 -tp=k8-64 -Mcache_align driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/pgi64/lib -lacml
pgf77 -tp=k8-32 -Mcache_align driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/pgi32/lib -lacml
will compile driver.f and link it to the ACML using 64-bit and 32-bit versions respectively. In the example above we are linking with the single-processor PGI version of ACML.
If you have an SMP machine and want to take best advantage of it, link against the PGI OpenMP version of ACML like this:
pgf77 -tp=k8-64 -mp -Mcache_align driver.f
-L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/pgi64_mp/lib -lacml_mp
pgf77 -tp=k8-32 -mp -Mcache_align driver.f
-L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/pgi32_mp/lib -lacml_mp
Note that the directories and library names involved now include the suffix _mp.
The -mp flag is important - it tells pgf77 to link with the appropriate compiler OpenMP run-time library. Without it you might get an "unresolved symbol" message at link time. The -Mcache_align flag is also important - it tells the compiler to align objects on cache-line boundaries.
The commands
pgcc -c -tp=k8-64 -mp -Mcache_align
-I/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/pgi64_mp/include driver.c
pgcc -tp=k8-64 -mp -Mcache_align driver.o
-L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/pgi64_mp/lib -lacml_mp -lpgftnrtl -lm
will compile driver.c and link it to the 64-bit ACML. Again, the -mp flag is important if you are linking to the PGI OpenMP version of ACML. The C compiler is instructed to search the directory /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/pgi64_mp/include for the ACML C header file acml.h, which should be included by driver.c, by using the switch "-I/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/pgi64_mp/include". Note that in the example we add the libraries -lpgftnrtl and -lm to the link command, so that required PGI compiler run-time libraries are found.
Note that since ACML version 3.5.0, all PGI 64-bit variants are compiled with the PGI -Mlarge_arrays switch to allow use of larger data arrays (see PGI compiler documentation for more information). The special 'large array' variants that were distributed with earlier versions of ACML are therefore no longer required.
Similar commands apply for the Open64 versions of ACML. For example,
openf95 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/open64_64/lib -lacml
will compile driver.f and link it to the ACML using the 64-bit version.
The commands
opencc -c -I/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/open64_64/include driver.c
opencc driver.o -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/open64_64/lib -lacml -lfortran
will compile driver.c and link it to the 64-bit ACML. The switch
-I/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/open64_64/include
tells the C compiler to search directory /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/open64_64/include for the ACML C header file acml.h, which should be included by driver.c. Note that in the example we add the library -lfortran to the link command, so that the required Open64 compiler run-time library is found.
Similar commands apply for the NAGware f95 versions of ACML. For example,
f95 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/nag64/lib -lacml
f95 -32 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/nag32/lib -lacml
will compile driver.f and link it to the ACML using the 64-bit version and 32-bit version respectively.
Similar commands apply for the Intel ifort versions of ACML. For example,
ifort driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/ifort64/lib -lacml
will compile driver.f and link it to the ACML using the 64-bit version.
The commands
gcc -c -I/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/ifort64/include driver.c
ifort -nofor-main driver.o -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/ifort64/lib -lacml
will compile driver.c and link it to the 64-bit ACML. The switch
-I/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/ifort64/include
tells the C compiler to search directory /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/ifort64/include for the ACML C header file acml.h, which should be included by driver.c. Note that in the example we link the C program using the ifort compiler with the -nofor-main switch, so that required ifort compiler run-time libraries are found.
If you have an SMP machine and want to take best advantage of it, link against the ifort OpenMP version of ACML like this:
ifort -openmp driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/ifort64_mp/lib -lacml_mp
ifort -openmp driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/ifort32_mp/lib -lacml_mp
Note that the directories and library names involved now include the suffix _mp.
The -openmp flag is important - it tells ifort to link with the appropriate compiler OpenMP run-time library. Without it you might get an "unresolved symbol" message at link time.
The Absoft compiler af90 is compatible with the GNU compiler gfortran version of ACML, so long as the appropriate gfortran run-time libraries are installed on your system. If the Linux 64-bit gfortran version of ACML was installed in the default directory, /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64, then the command:
af90 -m64 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib -lacml -lgfortran
can be used to compile the program driver.f and link it to the ACML. Note that -gfortran links to the gfortran run-time library, which must be installed on your system.
The ACML Library is supplied in both static and shareable versions, libacml.a and libacml.so, respectively. By default, the commands given above will link to the shareable version of the library, libacml.so, if that exists in the directory specified. Linking with the static library can be forced either by using the compiler flag -static, e.g.
af90 -m64 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib -static \
-lacml -lgfortran -lrt
or by inserting the name of the static library explicitly in the command line, e.g.
af90 -m64 driver.f /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib/libacml.a -lgfortran -lrt
Notice that if the application program has been linked to the shareable ACML Library, then before running the program, the environment variable LD_LIBRARY_PATH must be set. Assuming that libacml.so was installed in the directory /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib, then LD_LIBRARY_PATH may be set by, for example, the C-shell command
setenv LD_LIBRARY_PATH /opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64/lib
(See the man page for ld(1) for more information about LD_LIBRARY_PATH.)
The command
af90 -m32 driver.f -L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran32/lib -lacml -lgfortran
will compile and link a 32-bit program with a 32-bit ACML.
If you have an SMP machine and want to take best advantage of it, link against the gfortran OpenMP version of ACML like this:
af90 -m64 driver.f
-L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran64_mp/lib -lacml_mp -lgfortran -lgomp
af90 -m32 driver.f
-L/opt/acmlVERSIONMAJ.VERSIONMIN.VERSIONPATCH/gfortran32_mp/lib -lacml_mp -lgfortran -lgomp
Note that the directories and library names involved now include the suffix _mp. Also note that it is necessary to link to the gfortran run-time libraries -lgfortran -lgomp, both of which must be installed on your system.
It may be possible to link to some versions of ACML using compilers other than those already mentioned, if they are compatible with one of the other versions. If you do this, it may be necessary to link to the run-time library of the compiler used to build the ACML you link to, in order to satisfy run-time symbols. Since doing this is very compiler-specific, we give no further details here.