<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — Coarray Fortran DLL can be possibly called from C++ or C#]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=836&amp;type=atom" />
	<updated>2022-02-22T12:30:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=836</id>
		<entry>
			<title type="html"><![CDATA[Re: Coarray Fortran DLL can be possibly called from C++ or C#]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3891#p3891" />
			<content type="html"><![CDATA[<p>It would be possible to do if you used an external executable rather than a DLL.&nbsp; Unfortunately, Coarray implementations (and compiler support for Coarray implementations) focus on multiple images of a program running.&nbsp; If there were a Coarray implementation that relied on threads rather than separate processes, you&#039;d be able to do what you&#039;re suggesting. </p><p>The issue is that the compiler we ship, GNU Fortran, assumes that Coarrays, regardless of the implementation, will be using multiple images.&nbsp; This decision isn&#039;t arbitrary, though.&nbsp; Many of the assumptions that the compiler itself makes assumes that the program is running in a self-contained image.&nbsp; For example, when a variable has the <strong>SAVE</strong> attribute, meaning its value will persist across calls to a procedure, Coarray Fortran assumes that the saved value is local to that Coarray worker.&nbsp; Yet the compiler treats it as a special static variable local to that process.&nbsp; If Coarrays relied on threads, every thread, in theory, would see the same value in that variable because it is local to that process, not thread.&nbsp; Those odd, little corners of the language makes implementing Coarrays without multiple processes highly problematic.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2022-02-22T12:30:52Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3891#p3891</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Coarray Fortran DLL can be possibly called from C++ or C#]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3886#p3886" />
			<content type="html"><![CDATA[<p>Jeff, Thank for your reply.<br />My program is DLL implementation, to achieve complex parallelism, we selected Coarray. But we find that no compiler supports running Coarray in a DLL now.</p>]]></content>
			<author>
				<name><![CDATA[Jessen]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=4023</uri>
			</author>
			<updated>2022-02-19T07:25:45Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3886#p3886</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Coarray Fortran DLL can be possibly called from C++ or C#]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3851#p3851" />
			<content type="html"><![CDATA[<p>With Simply Fortran on Windows, the use of coarrays is complicated by the need for the executable to launch in a specialized manner.&nbsp; Coarrays (at least our implementation and most others) rely on multiple images of the executable running in parallel.&nbsp; When a Fortran executable using coarrays starts, our library launches the executable a number of times more (the number of CPU cores present by default) with special command line flags notifying the images of how to communicate with one another.&nbsp; The library hooks into the documented Fortran runtime API to handle startup and information passing.</p><p>Launching this coarray program from a DLL would be exceptionally complicated because it needs to actually start additional <em>processes</em> for the Fortran coarray handling.&nbsp; I&#039;m not exactly sure how this situation would be handled from a call originating from a C++ of C# program because it would skip the multiple-image-initialization step.&nbsp; </p><p>I think it might be more useful to look at what you wish to achieve.&nbsp; You could have your C++ or C# program launch a Fortran executable that uses coarrays and read results from a file possibly.&nbsp; If you&#039;re just looking to perform some parallel computations, OpenMP programming might be somewhat more convenient since it relies only on threads, which wouldn&#039;t run into the multiple-image issues I described.</p><p>Can you tell us more about what you&#039;re trying to achieve?&nbsp; Coarrays aren&#039;t necessarily the best answer for parallel computations.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2022-01-22T06:05:02Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3851#p3851</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Coarray Fortran DLL can be possibly called from C++ or C#]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3849#p3849" />
			<content type="html"><![CDATA[<p>I am trying to understand how a Coarray Fortran DLL can be possibly called from C++ or C#. Do you have any suggestion or example? </p><p>Thanks in advanced!</p>]]></content>
			<author>
				<name><![CDATA[Jessen]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=4023</uri>
			</author>
			<updated>2022-01-21T15:55:08Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3849#p3849</id>
		</entry>
</feed>
