<div>A quick update and a follow up question.  I was able to successfully call into the CUDA code from compiled scheme. (Horray!)</div><div><br></div><div>But now I don't seem to be able to load the object file from the interpreter, even when I start it as gsc.  </div>
<div><br></div><div>I even tried renaming my shared object (build with -fPIC) to end in .o1.  But still no luck using (load "myobject.o") or (load "myobject.o1").</div><div><br></div><div>Is there a special call to load a shared library into the interpreter?  Alternatively, is there a way to invoke an interpreter REPL from within a compiled executable?</div>
<div><br></div><div>Thanks.</div><div><br></div><div>Jason</div><div><br></div><div>## demonstration of problem loading .o file (full compilation steps and source attached for the curious)</div><div><br></div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><div>
jaten@afarm:~/NVIDIA_GPU_Computing_SDK/C/src/matrixMul$ gsc</div><div>Gambit v4.6.0</div><div><br></div><div>> (load "obj/x86_64/release/matrixMul.cu")</div><div>*** ERROR IN (console)@1.1 -- No such file or directory</div>
<div><br></div><div>(load "obj/x86_64/release/matrixMul.cu")</div><div>1> (load "obj/x86_64/release/matrixMul.cu.o1")</div><div>*** WARNING -- Could not find C function: "____20_matrixMul_2e_cu_2e_o1"</div>
<div>*** ERROR IN (console)@2.1 -- /home/jaten/NVIDIA_GPU_Computing_SDK/C/src/matrixMul/obj/x86_64/release/matrixMul.cu.o1: only ET_DYN and ET_EXEC can be loaded</div><div>(load "obj/x86_64/release/matrixMul.cu.o1")</div>
<div>2> </div><div>1> </div><div>> (load "obj/x86_64/release/matrixMul.cu.o")</div><div>*** ERROR IN "obj/x86_64/release/matrixMul.cu.o"@1.5 -- Illegal character: #\x02</div><div>1> </div><div>
> (load "obj/x86_64/release/matrixMul.cu")</div><div>*** ERROR IN (console)@4.1 -- No such file or directory</div><div>(load "obj/x86_64/release/matrixMul.cu")</div><div>1> </div><div>> (load "prog.scm")</div>
<div>*** ERROR IN "prog.scm"@2.1 -- Interpreter does not support ##c-declare</div><div>1> </div><div>> </div><div>*** EOF again to exit</div><div><br></div><div><br></div><div><br></div><div><br></div><div>
jaten@afarm:~/NVIDIA_GPU_Computing_SDK/C/src/matrixMul$ cat prog.scm </div><div><br></div><div>(c-declare "extern double foo(int a, int b);")</div><div>(define foo (c-lambda (int int) double "foo"))</div>
<div>(println (foo 11 22)) ;; test it...</div><div><br></div><div><br></div><div>jaten@afarm:~/NVIDIA_GPU_Computing_SDK/C/src/matrixMul$ ./prog</div><div>Device 0: "GeForce GTX 460" with Compute 2.1 capability</div>
<div>Error when parsing command line argument string.</div><div><br></div><div>Using Matrix Sizes: A(80 x 160), B(80 x 80), C(80 x 160)</div><div><br></div><div>Run Kernels...</div><div><br></div><div>matrixMul, Throughput = 79.8960 GFlop/s, Time = 0.00003 s, Size = 2048000 Ops, NumDevsUsed = 1, Workgroup = 256</div>
<div><br></div><div>Check against Host computation...</div><div><br></div><div>PASSED </div><div><br></div><div>foo() called: Test code integrating Gambit Scheme with nVIDIA CUDA-C code complete!</div><div>Answer to foo(11,22) =</div>
<div>.02268041237113402</div><div>jaten@afarm:~/NVIDIA_GPU_Computing_SDK/C/src/matrixMul$ </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></span></font><br><div class="gmail_quote">On Sun, Feb 13, 2011 at 6:47 PM, Jason E. Aten <span dir="ltr"><<a href="mailto:j.e.aten@gmail.com">j.e.aten@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><font color="#534741" face="Arial, Verdana, sans-serif">I'll try to answer, but feel free to ask for clarification if I don't illuminate the topic.</font></div>
<div><font color="#534741" face="Arial, Verdana, sans-serif"><br>
</font></div><div><font color="#534741" face="Arial, Verdana, sans-serif">nvcc is really just a coordinator for many calls.  nvcc makes a series of calls, producing intermediate code (PTX files), that can then be just-in-time compiled into final (.cubin) architecture specific code by the nvida libraries.  In a sense, yes, it compiles source code, but then breaks out kernel code to be targeted to the GPU device architecture(s).  Later in the compilation sequence they all get merged into one file.</font></div>

<div><font color="#534741" face="Arial, Verdana, sans-serif"><br></font></div><div><span style="font-family:Arial, Verdana, sans-serif;font-size:13px;color:rgb(83, 71, 65)">I attach an example of a C++ file that includes at the top in the comments the 15 commands issued by the nvcc nVidia compiler coordinator.  The final (15th command) is the link stage, producing a final executable that depends upon several shared libraries.  The matrixMul.cu example from the SDK is consolidated into one file, matrixMul.cu.txt, and the commands used to assemble the final binary broken out at the top of the file.</span></div>

<div><br></div>Thanks again.<div class="im"><div><br></div><div>Best regards,</div><div>Jason<br><br></div><div><br>-- <br>Jason E. Aten, Ph.D.<br></div><div><br></div></div><div><div></div><div class="h5"><div><br><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>
> Perhaps I don't understand how nvcc and CUDA work.  Is it the case that all source code is compiled by nvcc and then linked to create an executable, or is there some other preprocessor/compiler/linker/loader that is involved?<br>


><br>
> Marc<br>
><br>
><br>
</div></div></blockquote></div><br><br clear="all"><br><br>
</div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Jason E. Aten, Ph.D.<br><br><br>