12.07.2015 Views

PGI User's Guide

PGI User's Guide

PGI User's Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 13. Programming Considerations for 64-Bit Environmentsstack spaceStack space can be a problem for data that is stack-based. In Win64, stack spacecan be increased by using this link-time switch, where N is the desired stack size:–Wl,-stack:NNoteIn linux86-64, stack size is increased in the environment. Settingstacksize to unlimited often is not large enough.page swappingconfigured spacesupport for largeaddress offsets inobject file formatlimit stacksize new_size ! in cshulimit –s new_size ! in bashIf your executable is much larger than the physical size of memory, page swappingcan cause it to run dramatically slower; it may even fail. This is not a compilerproblem. Try smaller data sets to determine whether or not a problem is due topage thrashing.Be sure your linux86-64 system is configured with swap space sufficiently large tosupport the data sets used in your application(s). If your memory+swap space isnot sufficiently large, your application will likely encounter a segmentation fault atruntime.Arrays that are not dynamically allocated are limited by how the compiler canexpress the ‘distance’ between them when generating code. A field in the objectfile stores this ‘distance’ value, which is limited to 32-bits on Win32, Win64,linux86, and linux86-64 with –mcmodel=small. It is 64-bits on linux86-64 with –mcmodel=medium.NoteWithout the 64-bit offset support in the object file format, large arrayscannot be declared statically or locally stack-based.Medium Memory Model and Large Array in CConsider the following example, where the aggregate size of the arrays exceeds 2GB.% cat bigadd.#include #define SIZE 600000000 /* > 2GB/4 */static float a[SIZE], b[SIZE];intmain(){long long i, n, m;float c[SIZE]; /* goes on stack */n = SIZE;m = 0;for (i = 0; i < n; i += 10000) {a[i] = i + 1;b[i] = 2.0 * (i + 1);c[i] = a[i] + b[i];Example 13.1. Medium Memory Model and Large Array in C171

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!