0 Replies Latest reply on Aug 23, 2008 9:53 AM by Yuriy.Bogomolov

    Using CAL from .NET

      Having problems with .NET + CAL

      Hello. I'm trying to use CAL from MS .NET. I'm new to GPU programming, thus I started with "hellocal" example.

      I made managed C++ DLL-project with following code:


      #include "stdafx.h"
      #include "calcl.h"

      using namespace System;

      #pragma unmanaged

      // CAL Testing...
      std::string programIL = 
      "dcl_input_interp(linear) v0.xy\n"
      "dcl_output_generic o0\n"
      "dcl_cb cb0[1]\n"
      "sample_resource(0)_sampler(0) r0, v0.xyxx\n"
      "mul o0, r0, cb0[0]\n"

      extern "C" __declspec(dllexport) void CAL_Test()
          // Here goes code from hellocal's main();


      #pragma managed

      // Some .NET code;


      It compiles successfully, and CAL_Test() Procedure can be called normally (I tried it on general C++.NET console application).

      But when I try to use this assembly form C# project, I got an error:

      Invalid Buffer, unable to write to file
      Fatal Error: Translator succeeded but returned null pointer
      Fatal Error: Failed to compile program with IL front-end compiler!
      Program compilation failed. Exiting.

      Corresponding C#-code:

      using Mg2Umg_Test;
      using System.Runtime.InteropServices;

      namespace ConsoleApplication1
       class Program
        public static extern void CAL_Test();

        static void Main(string[] args)

      What do I do wrong? How can I make possible to use CAL form .NET application?