[fpc-pascal] Common OpenMP syntax?
Steve Williams
stevewilliams at kromestudios.com
Thu Jul 20 11:41:25 CEST 2006
Florian Klaempfl wrote:
> I'am currently thinking about implementing OpenMP support in FPC.
> However, there is currently (to my knowledge) no pascal syntax defined
> for OpenMp support. Do you think we can find a common syntax to simplify
> things for users? I've some ideas how it be done, but I want to hear
> other ideas first so they are maybe better if they aren't influenced by
> my ideas :)
>
> I started also a wiki page about it
> http://www.freepascal.org/wiki/index.php/OpenMP_support where ideas can
> be written down and shared.
>
I would suggest something along the lines of the C/C++ implementation,
but using the Pascal form of compiler directives.
Using some of the documented examples in the v2.5 spec:
Example A.1.1:
procedure a1(n: Integer; a: PSingleArray; b: PSingleArray);
var
i: Integer;
begin
{$omp parallel for}
for i := 1 to n - 1 do
b^[i] := (a^[i] + a^[i - 1]) / 2.0;
end;
Example A.5.1:
uses omp;
begin
omp_set_dynamic(1);
{$omp parallel num_threads(10)}
begin
(* Do work here *)
end;
end;
Example A.13.1:
interface
function dequeue(var a: Single): Integer;
procedure work(i: Integer; var a: Single);
implementation
procedure a13(var x: Single; var y: Single);
var
ix_next, iy_next: Integer;
begin
{$omp parallel shared(x, y) private(ix_next, iy_next)}
begin
{$omp critical (xaxis)}
ix_next := dequeue(x);
work(ix_next, x);
{$omp critical (yaxis)}
iy_next := dequeue(y);
work(iy_next, y);
end;
end;
--
Sly
This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.
More information about the fpc-pascal
mailing list