Next: , Previous: Linking/Linux, Up: General


2.3 Accessing the Library (Microsoft Windows)

2.3.1 Accessing the Library under 32-bit Windows using GNU g77/gcc

Under Microsoft Windows(R) , for the g77/gcc version of ACML it is assumed that you have the Cygwin UNIX-like tools installed (see http://www.cygwin.com/), including the g77/gcc compiler and associated tools. Assuming you have installed the ACML in the default place, then in a DOS command prompt window, the command

     g77 driver.f "c:\Program Files\AMD\acml3.6.1\gnu32\lib\libacml.a"

can be used to link the application program driver.f to the static library version of the ACML.

The g77 version of the ACML Library is supplied in both static and shareable versions, libacml.a and libacml.dll, respectively. The command given above links to the static version of the library, libacml.a. To link to the DLL version, the command

     g77 driver.f "c:\Program Files\AMD\acml3.6.1\gnu32\lib\libacml.dll"

can be used. Notice that if the application program has been linked to the DLL version of the ACML Library, then before running the program, the environment variable PATH must have been set to include the location of the DLL, for example by the DOS command:

     PATH="c:\Program Files\AMD\acml3.6.1\gnu32\lib";%PATH%

where it was assumed that libacml.dll was installed in the directory "c:\Program Files\AMD\acml3.6.1\gnu32\lib". Alternatively, the PATH environment variable may be set in the system category of the Windows control panel.

The command

     gcc "-Ic:\Program Files\AMD\acml3.6.1\gnu32\include" driver.c
         "c:\Program Files\AMD\acml3.6.1\gnu32\lib\libacml.a" -lg2c

will compile driver.c and link it to the 32-bit g77/gcc version of ACML. The switch "-Ic:\Program Files\AMD\acml3.6.1\gnu32\include" tells the gcc compiler to search directory "c:\Program Files\AMD\acml3.6.1\gnu32\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.3.2 Accessing the Library under 32-bit Windows using PGI compilers pgf77/pgf90/Microsoft C

To use the 32-bit Windows PGI version of ACML, use a command like

     pgf77 -Munix driver.f
           "c:\Program Files\AMD\acml3.6.1\pgi32\lib\libacml_dll.lib"

where libacml_dll.lib is the import library for the ACML DLL. Note that it is important to use the compiler switch -Munix in order to tell the compiler to use the same calling convention as was used to build ACML.

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 -Munix -mp driver.f
           "c:\Program Files\AMD\acml3.6.1\pgi32\lib\libacml_mp_dll.lib"

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

For the OpenMP version of ACML, if you link to the static library libacml_mp.lib rather than the DLL import library libacml_mp_dll.lib, you will need to use the PGI compiler flag -mp in order to tell the compiler to link with the appropriate compiler OpenMP run-time library. Without it you might get an "unresolved symbol" message at link time. This should not be necessary when linking to the ACML DLL because the DLL itself knows that it depends on the run-time library; but using the -mp flag in any case will do no harm.

To compile and link a C program using the Microsoft C command line compiler, cl, the commands

     cl "-Ic:\Program Files\AMD\acml3.6.1\pgi32\include"
          /MD driver.c
          "c:\Program Files\AMD\acml3.6.1\pgi32\lib\libacml_dll.lib"
     cl "-Ic:\Program Files\AMD\acml3.6.1\pgi32_mp\include"
          /MD driver.c
          "c:\Program Files\AMD\acml3.6.1\pgi32_mp\lib\libacml_mp_dll.lib"

will link against the single-threaded DLL and multi-threaded versions of ACML respectively.

2.3.3 Accessing the Library under 32-bit Windows using Microsoft C or Intel Fortran

To use the 32-bit Windows MSC/Intel Fortran version of ACML, use a command like

     ifort /threads /libs:dll driver.f
           "c:\Program Files\AMD\acml3.6.1\ifort32\lib\libacml_dll.lib"

where libacml_dll.lib is the import library for the ACML DLL.

In the example above we are linking with the single-processor ifort version of ACML.

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 /libs:dll -Qopenmp driver.f
       c:\acml3.6.1\ifort32_mp\lib\libacml_mp_dll.lib

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

For the OpenMP version of ACML, if you link to the static library libacml_mp.lib rather than the DLL import library libacml_mp_dll.lib, you will need to use the ifort compiler flag -Qopenmp in order to tell the compiler to link with the appropriate compiler OpenMP run-time library. Without it you might get an "unresolved symbol" message at link time. This should not be necessary when linking to the ACML DLL because the DLL itself knows that it depends on the run-time library; but using the -Qopenmp flag in any case will do no harm.

To compile and link a C program using the Microsoft C command line compiler, cl, the commands

     cl "-Ic:\Program Files\AMD\acml3.6.1\ifort32\include"
          /MD driver.c
          "c:\Program Files\AMD\acml3.6.1\ifort32\lib\libacml_dll.lib"
     cl "-Ic:\Program Files\AMD\acml3.6.1\ifort32_mp\include"
          /MD driver.c
          "c:\Program Files\AMD\acml3.6.1\ifort32_mp\lib\libacml_mp_dll.lib"

will link against the single-threaded DLL and multi-threaded versions of ACML respectively.

ACML can also be linked from inside a development environment such as Microsoft Visual Studio or Visual Studio.NET. Again, it is important to get compilation options correct. The directory acml3.6.1\ifort32\examples\Projects contains a few sample Visual Studio project directories showing how this can be done.

Note that in both examples above we linked to a DLL version of ACML, and so before running the resulting programs the environment variable PATH must be set to include the location of the DLL. For example, assuming that libacml_dll.dll was installed in "c:\Program Files\AMD\acml3.6.1\ifort32\lib", PATH may be set by, for example, the DOS command

     PATH="c:\Program Files\AMD\acml3.6.1\ifort32\lib";%PATH%

Alternatively, the PATH environment variable may be set in the system category of the Windows control panel.

ACML also comes as a static (non-DLL) library, named libacml.lib, in the same directory as the DLL. If you link to the static library instead of the DLL import library then there is no need to set the PATH.

2.3.4 Accessing the Library under 32-bit Windows using the Compaq Visual Fortran compiler

The win32 Intel Fortran variant of ACML can be used with the Compaq Visual Fortran compiler as follows:

     f90 /iface:cref,nomixed_str_len_arg /threads /libs:dll driver.f
           "c:\Program Files\AMD\acml3.6.1\ifort32\lib\libacml_dll.lib"

where f90 is the Compaq Visual Fortran command line compiler and libacml_dll.lib is the import library for the ACML DLL. The switch /iface:cref,nomixed_str_len_arg used on the f90 compiler command line is important - it tells the compiler to use a calling convention equivalent to the default Intel Fortran calling convention, rather than the default cvf _stdcall calling convention. If you forget to use this switch your program is likely to crash on execution.

2.3.5 Accessing the Library under 32-bit Windows using the Salford FTN95 compiler

The win32 Intel Fortran variant of ACML can be used with the Salford ftn95 compiler as follows:

     ftn95 driver.f

The resulting object file can be linked using the Salford linker, slink, for example like this:

     slink driver.obj install_dir\libacml_dll.dll

where install_dir is the location of the DLL. The full pathname of install_dir should be specified to the DLL and should be enclosed within quotes if it contains spaces. It is worth emphasising that the linker should link directly against the DLL itself, not the libacml_dll.lib import library.

2.3.6 Accessing the Library under 64-bit Windows using PGI compilers pgf77/pgf90/pgcc

Under 64-bit versions of Windows, ACML 3.6.1 comes as a static (.LIB) library or a DLL.

To link with the 64-bit Windows DLL library PGI version of ACML, in a DOS command prompt use a command like

     pgf77 -Mdll driver.f c:/acml3.6.1/win64/lib/libacml_dll.lib

where libacml_dll.lib is the import library for the DLL. In the example above we are linking with the single-processor WIN64 version of ACML.

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

     pgf77 -Mdll -mp driver.f c:/acml3.6.1/win64_mp/lib/libacml_mp_dll.lib

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

For the OpenMP version of ACML, if you link to the static library libacml_mp.lib rather than the DLL import library libacml_mp_dll.lib, you will need to use the PGI compiler flag -mp in order to tell the compiler to link with the appropriate compiler OpenMP run-time library. Without it you might get an "unresolved symbol" message at link time. This should not be necessary when linking to the ACML DLL because the DLL itself knows that it depends on the run-time library; but using the -mp flag in any case will do no harm.

Note that the performance of OpenMP code produced with the PGI WIN64 compilers depends on environment variables named MP_BIND and MP_SPIN, which control how multiple threads behave (see PGI compiler documentation for discussion of these variables). For ACML, empirical experiments show that higher values of MP_SPIN than the default are likely to give better performance. We recommend that users set MP_BIND=yes and MP_SPIN=100000000.

Under WIN64, to compile and link a C program, the commands

     pgcc -Mdll driver.c -Ic:/acml3.6.1/win64/include
          c:/acml3.6.1/win64/lib/libacml_dll.lib
     pgcc -Mdll -mp driver.c -Ic:/acml3.6.1/win64_mp/include
          c:/acml3.6.1/win64_mp/lib/libacml_mp_dll.lib

will link against the single-threaded DLL and multi-threaded versions of ACML respectively.

To use the Microsoft C command line compiler, cl, use commands like this:

     cl driver.c -Ic:/acml3.6.1/win64/include
          c:/acml3.6.1/win64/lib/libacml_dll.lib
     cl driver.c -Ic:/acml3.6.1/win64_mp/include
          c:/acml3.6.1/win64_mp/lib/libacml_mp_dll.lib

for single- and multi-threaded ACML variants respectively.

2.3.7 Accessing the Library under 64-bit Windows using Microsoft C or Intel Fortran

Under 64-bit versions of Windows, ACML 3.6.1 comes as a static (.LIB) library or a DLL.

To link with the 64-bit Windows DLL library Intel Fortran version of ACML, in a DOS command prompt use a command like

     ifort /libs:dll driver.f c:\acml3.6.1\ifort64\lib\libacml_dll.lib

where libacml_dll.lib is the import library for the DLL. In the example above we are linking with the single-processor ifort version of ACML.

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 /libs:dll -Qopenmp driver.f
       c:\acml3.6.1\win64_mp\lib\libacml_mp_dll.lib

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

For the OpenMP version of ACML, if you link to the static library libacml_mp.lib rather than the DLL import library libacml_mp_dll.lib, you will need to use the ifort compiler flag -Qopenmp in order to tell the compiler to link with the appropriate compiler OpenMP run-time library. Without it you might get an "unresolved symbol" message at link time. This should not be necessary when linking to the ACML DLL because the DLL itself knows that it depends on the run-time library; but using the -Qopenmp flag in any case will do no harm.

Under WIN64, to compile and link a C program using the Microsoft C command line compiler, cl, the commands

     cl driver.c -Ic:/acml3.6.1/ifort64/include
          c:/acml3.6.1/ifort64/lib/libacml_dll.lib
     cl driver.c -Ic:/acml3.6.1/ifort64_mp/include
          c:/acml3.6.1/ifort64_mp/lib/libacml_mp_dll.lib

will link against the single-threaded DLL and multi-threaded versions of ACML respectively.