<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Thank you very much guys. I in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034447#M43384</link>
    <description>&lt;P&gt;Thank you very much guys. I found the problem. In my software the Intel libraries where deployed together with our executable. So, for some reason, something conflict when tried to load the Intel libraries when launching the offloaded code. When I stopped deploying then, the problem was solved. As I'm still in a evaluation phase, I don't care about not deploying them, but in the future, this is something I would have to take care.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jan 2015 02:33:49 GMT</pubDate>
    <dc:creator>Silva__Rafael</dc:creator>
    <dc:date>2015-01-21T02:33:49Z</dc:date>
    <item>
      <title>Fortran Calling C Offloaded Function</title>
      <link>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034443#M43380</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;

&lt;P&gt;&amp;nbsp; I would like to know if it is possible to do a code like this:&lt;/P&gt;

&lt;P&gt;!dir$ offload begin target (mic:0)&lt;/P&gt;

&lt;P&gt;call C_SUBROUTINE(x, y)&lt;/P&gt;

&lt;P&gt;!dir$ end offload&lt;/P&gt;

&lt;P&gt;Where the subroutine code is:&lt;/P&gt;

&lt;P&gt;__attribute__ ((target(mic:0)))&lt;BR /&gt;
	void c_subroutine_(float * __restrict x, float * __restrict y)&lt;BR /&gt;
	{ &amp;nbsp;&lt;/P&gt;

&lt;P&gt;(...)&lt;/P&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;Where x and y are arrays of floats. I've tried but I'm getting invalid pointer error when the subroutine is called, even including "!dir$ attributes offload:mic :: C_SUBROUTINE" inside the calling Fortran subroutine.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 03:54:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034443#M43380</guid>
      <dc:creator>Silva__Rafael</dc:creator>
      <dc:date>2014-12-28T03:54:42Z</dc:date>
    </item>
    <item>
      <title>Just try them from ints again</title>
      <link>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034444#M43381</link>
      <description>Just try them from ints again</description>
      <pubDate>Sun, 28 Dec 2014 17:03:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034444#M43381</guid>
      <dc:creator>Vidura_Dhananjaya</dc:creator>
      <dc:date>2014-12-28T17:03:12Z</dc:date>
    </item>
    <item>
      <title>Diko, I'm not sure I</title>
      <link>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034445#M43382</link>
      <description>&lt;P&gt;Diko, I'm not sure I understood you suggestion. Do you mean to use integers? But I need floats, do it with integers does not solve my problem.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 17:30:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034445#M43382</guid>
      <dc:creator>Silva__Rafael</dc:creator>
      <dc:date>2014-12-28T17:30:50Z</dc:date>
    </item>
    <item>
      <title>Here is a short example.</title>
      <link>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034446#M43383</link>
      <description>&lt;P&gt;Here is a short example.&lt;/P&gt;

&lt;P&gt;example.f90:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program example_F_call_C
   USE ISO_C_BINDING
   USE MIC_LIB
   integer (C_INT) :: length = 5
   real (C_FLOAT)  :: answer = 0.0

   real (C_FLOAT), dimension(:), allocatable, target :: A, B

   interface
     real (C_FLOAT) function dotprod(length,A,B) bind(C,name="dotprod")
        USE ISO_C_BINDING
        integer (C_INT), VALUE :: length
        TYPE (C_PTR), VALUE :: A, B
     end function
   end interface

   ALLOCATE(A(length),B(length))

   do i = 1, length
      A(i) = REAL(i)
      B(i) = REAL((length+1) - i)
   end do

   ! calculate dot product of A and B
   !DIR$ ATTRIBUTES OFFLOAD : MIC :: dotprod
   !DIR$ OFFLOAD BEGIN target(mic) mandatory
       print "(A,i1)","Calc on card: ",OFFLOAD_GET_DEVICE_NUMBER()
       answer = dotprod(length, C_LOC(A), C_LOC(B))
   !DIR$ END OFFLOAD

   print "(F4.1)", answer

   do i = 1, length
      print "(F3.1,1x,F3.1)", A(i),B(i)
   end do

   DEALLOCATE(A,B)
end&lt;/PRE&gt;

&lt;P&gt;dotprod.c:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;__attribute__ ((target (mic)))
float dotprod(  int length, float *A, float *B )
{
    int i;
    float answer;
    answer = 0.0;

    for (i=0; i &amp;lt; length; i++) {
      answer += *(A+i) * *(B+i);
    }

    return answer;
}&lt;/PRE&gt;

&lt;P&gt;Build and execute as follows:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.1.133 Build 20141023

$ icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.1.133 Build 20141023

$ icc -c dotprod.c
$ ifort example.f90 dotprod.o -o example.exe

$ ./example.exe
Calc on card: 0
35.0
1.0 5.0
2.0 4.0
3.0 3.0
4.0 2.0
5.0 1.0&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 17:27:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034446#M43383</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2015-01-08T17:27:09Z</dc:date>
    </item>
    <item>
      <title>Thank you very much guys. I</title>
      <link>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034447#M43384</link>
      <description>&lt;P&gt;Thank you very much guys. I found the problem. In my software the Intel libraries where deployed together with our executable. So, for some reason, something conflict when tried to load the Intel libraries when launching the offloaded code. When I stopped deploying then, the problem was solved. As I'm still in a evaluation phase, I don't care about not deploying them, but in the future, this is something I would have to take care.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jan 2015 02:33:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034447#M43384</guid>
      <dc:creator>Silva__Rafael</dc:creator>
      <dc:date>2015-01-21T02:33:49Z</dc:date>
    </item>
    <item>
      <title>Glad you have your code</title>
      <link>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034448#M43385</link>
      <description>&lt;P&gt;Glad you have your code working. Let us know if you still face problems deploying w/Intel libraries in the future and we will help you resolve that.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jan 2015 10:56:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Fortran-Calling-C-Offloaded-Function/m-p/1034448#M43385</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2015-01-21T10:56:36Z</dc:date>
    </item>
  </channel>
</rss>

