Next: , Previous: BestLibrary, Up: General


2.2 Accessing the Library (Linux)

2.2.1 Accessing the Library under Linux using GNU g77/gcc

If the Linux 64-bit g77 version of ACML was installed in the default directory, /opt/acml3.6.1/gnu64, then the command:

     g77 -m64 driver.f -L/opt/acml3.6.1/gnu64/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.

     g77 -m64 driver.f -L/opt/acml3.6.1/gnu64/lib -static -lacml

or by inserting the name of the static library explicitly in the command line, e.g.

     g77 -m64 driver.f /opt/acml3.6.1/gnu64/lib/libacml.a

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, for example, by the C-shell command:

     setenv LD_LIBRARY_PATH /opt/acml3.6.1/gnu64/lib

where it is assumed that libacml.so was installed in the directory /opt/acml3.6.1/gnu64/lib (see the man page for ld(1) for more information about LD_LIBRARY_PATH.).

The command

     g77 -m32 driver.f -L/opt/acml3.6.1/gnu32/lib -lacml

will compile and link a 32-bit program with a 32-bit ACML.

To compile and link a 64-bit C program with a 64-bit ACML, invoke

     gcc -m64 -I/opt/acml3.6.1/gnu64/include driver.c
         -L/opt/acml3.6.1/gnu64/lib -lacml -lg2c

The switch "-I/opt/acml3.6.1/gnu64/include" tells the compiler to search the directory /opt/acml3.6.1/gnu64/include for the ACML C header file acml.h, which should be included by driver.c. Note that it is necessary to add the compiler run-time library -lg2c when linking the program.

2.2.2 Accessing the Library under Linux using GNU gfortran/gcc

If the Linux 64-bit gfortran version of ACML was installed in the default directory, /opt/acml3.6.1/gfortran64, then the command:

     gfortran -m64 driver.f -L/opt/acml3.6.1/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/acml3.6.1/gfortran64/lib -static -lacml

or by inserting the name of the static library explicitly in the command line, e.g.

     gfortran -m64 driver.f /opt/acml3.6.1/gfortran64/lib/libacml.a

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/acml3.6.1/gfortran64/lib, then LD_LIBRARY_PATH may be set by, for example, the C-shell command

     setenv LD_LIBRARY_PATH /opt/acml3.6.1/gfortran64/lib

(See the man page for ld(1) for more information about LD_LIBRARY_PATH.)

The command

     gfortran -m32 driver.f -L/opt/acml3.6.1/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/acml3.6.1/gfortran64_mp/lib -lacml_mp
     gfortran -fopenmp -m32 driver.f
              -L/opt/acml3.6.1/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/acml3.6.1/gfortran64/include driver.c
         -L/opt/acml3.6.1/gfortran64/lib -lacml -lgfortran

The switch "-I/opt/acml3.6.1/gfortran64/include" tells the compiler to search the directory /opt/acml3.6.1/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.

2.2.3 Accessing the Library under Linux using PGI compilers pgf77/pgf90/pgcc

Similar commands apply for the PGI versions of ACML. For example,

     pgf77 -tp=k8-64 -Mcache_align driver.f -L/opt/acml3.6.1/pgi64/lib -lacml
     pgf77 -tp=k8-32 -Mcache_align driver.f -L/opt/acml3.6.1/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/acml3.6.1/pgi64_mp/lib -lacml_mp
     pgf77 -tp=k8-32 -mp -Mcache_align driver.f
           -L/opt/acml3.6.1/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/acml3.6.1/pgi64_mp/include driver.c
     pgcc -tp=k8-64 -mp -Mcache_align driver.o
           -L/opt/acml3.6.1/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/acml3.6.1/pgi64_mp/include for the ACML C header file acml.h, which should be included by driver.c, by using the switch "-I/opt/acml3.6.1/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.

2.2.4 Accessing the Library under Linux using PathScale compilers pathf90/pathcc

Similar commands apply for the PathScale versions of ACML. For example,

     pathf90 driver.f -L/opt/acml3.6.1/pathscale64/lib -lacml

will compile driver.f and link it to the ACML using the 64-bit version.

The commands

     pathcc -c -I/opt/acml3.6.1/pathscale64/include driver.c
     pathcc driver.o -L/opt/acml3.6.1/pathscale64/lib -lacml -lpathfortran

will compile driver.c and link it to the 64-bit ACML. The switch

     -I/opt/acml3.6.1/pathscale64/include

tells the C compiler to search directory /opt/acml3.6.1/pathscale64/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 -lpathfortran to the link command, so that the required PathScale compiler run-time library is found.

If you have an SMP machine and want to take best advantage of it, link against the PathScale OpenMP version of ACML like this:

     pathf90 -mp driver.f -L/opt/acml3.6.1/pathscale64_mp/lib -lacml_mp
     pathf90 -mp driver.f -L/opt/acml3.6.1/pathscale32_mp/lib -lacml_mp

Note that the directories and library names involved now include the suffix _mp.

The -mp flag is important - it tells pathf90 to link with the appropriate compiler OpenMP run-time library. Without it you might get an "unresolved symbol" message at link time.

The commands

     pathcc -c -mp -I/opt/acml3.6.1/pathscale64_mp/include driver.c
     pathcc -mp driver.o -L/opt/acml3.6.1/pathscale64_mp/lib -lacml_mp
            -lpathfortran

will compile driver.c and link it to the 64-bit ACML. Again, the -mp flag is important if you are linking to the PathScale OpenMP version of ACML. The C compiler is instructed to search the directory /opt/acml3.6.1/pathscale64_mp/include for the ACML C header file acml.h, which should be included by driver.c, by using the switch "-I/opt/acml3.6.1/pathscale64_mp/include". Note that in the example we add the library -lpathfortran to the link command, so that a required PathScale compiler run-time library is found.

2.2.5 Accessing the Library under Linux using the NAGWare f95 compiler

Similar commands apply for the NAGware f95 versions of ACML. For example,

     f95 driver.f -L/opt/acml3.6.1/nag64/lib -lacml
     f95 -32 driver.f -L/opt/acml3.6.1/nag32/lib -lacml

will compile driver.f and link it to the ACML using the 64-bit version and 32-bit version respectively.

2.2.6 Accessing the Library under Linux using the Intel ifort compiler

Similar commands apply for the Intel ifort versions of ACML. For example,

     ifort driver.f -L/opt/acml3.6.1/ifort64/lib -lacml

will compile driver.f and link it to the ACML using the 64-bit version.

The commands

     gcc -c -I/opt/acml3.6.1/ifort64/include driver.c
     ifort -nofor-main driver.o -L/opt/acml3.6.1/ifort64/lib -lacml

will compile driver.c and link it to the 64-bit ACML. The switch

     -I/opt/acml3.6.1/ifort64/include

tells the C compiler to search directory /opt/acml3.6.1/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/acml3.6.1/ifort64_mp/lib -lacml_mp
     ifort -openmp driver.f -L/opt/acml3.6.1/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.

2.2.7 Accessing the Library under Linux using compilers other than GNU, PGI, PathScale, NAGWare or Intel

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.