static OMPCommon.TestCallback cb = new OMPCommon.TestCallback(Test);
static void Main(string[] args)
{
OMPCommon.Helper.UseOMP(cb);
Console.ReadLine();
}
static void Test(int i)
{
Console.WriteLine(i);
Thread.Sleep(5000);
}
// Set VS2008 C++ project Properties -->Configure --> C/C++ Language --> Support OpenMP
#include <omp.h>
#pragma once
using namespace System;
namespace OMPCommon {
public delegate void TestCallback(int i);
public ref class Helper
{
public:
static void UseOMP(TestCallback^ cb)
{
omp_set_num_threads(10);
#pragma omp parallel for
for (int i=0;i<20; i++)
{
cb(i);
}
}
};
}
Wednesday, November 5, 2008
Call C++ Open MP from C# code
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment