Permalink
Browse files

Fixing several problems: GCHandle.Free() when it shouldn't; fix type …

…casting to GPU BCL methods; finding .LIB file for GPU BCL when tests aren't set up correctly. Comb test works, sort of, but only if 'swaps' variable is an Int32. This is because the meta used by JITER does not correspond to what is layed out via BUFFER. This will need to be fixed, using the meta for the GPU.
  • Loading branch information...
kaby76 committed Mar 14, 2018
1 parent 9f14e66 commit fba9328a82a6f39cc3b49cfcd5be705624243688
Showing with 34 additions and 9 deletions.
  1. +11 −7 Campy.Compiler/inst.cs
  2. +21 −0 Campy.Compiler/runtime.cs
  3. +2 −2 Campy/Parallel.cs
@@ -1315,7 +1315,7 @@ public override INST Convert(JITER converter, STATE state)
LLVM.SetAlignment(param_buffer, 64);
//LLVM.PositionBuilderAtEnd(Builder, this.Block.BasicBlock);
var base_of_parameters = LLVM.BuildPointerCast(Builder, param_buffer,
LLVM.PointerType(LLVM.Int64Type(), 0), "i" + instruction_id++);
LLVM.PointerType(LLVM.Int64Type(), 0), "i" + instruction_id++);
for (int i = mr.Parameters.Count - 1; i >= 0; i--)
{
VALUE p = state._stack.Pop();
@@ -1341,12 +1341,16 @@ public override INST Convert(JITER converter, STATE state)
//LLVM.PositionBuilderAtEnd(Builder, this.Block.BasicBlock);
// Set up call.
var pt = LLVM.BuildPointerCast(Builder, t.V,
LLVM.PointerType(LLVM.VoidType(), 0), "i" + instruction_id++);
var pp = LLVM.BuildPointerCast(Builder, param_buffer,
LLVM.PointerType(LLVM.VoidType(), 0), "i" + instruction_id++);
var pr = LLVM.BuildPointerCast(Builder, return_buffer,
LLVM.PointerType(LLVM.VoidType(), 0), "i" + instruction_id++);
var pt = LLVM.BuildPtrToInt(Builder, t.V, LLVM.Int64Type(), "i" + instruction_id++);
var pp = LLVM.BuildPtrToInt(Builder, param_buffer, LLVM.Int64Type(), "i" + instruction_id++);
var pr = LLVM.BuildPtrToInt(Builder, return_buffer, LLVM.Int64Type(), "i" + instruction_id++);
//var pt = LLVM.BuildPointerCast(Builder, t.V,
// LLVM.PointerType(LLVM.VoidType(), 0), "i" + instruction_id++);
//var pp = LLVM.BuildPointerCast(Builder, param_buffer,
// LLVM.PointerType(LLVM.VoidType(), 0), "i" + instruction_id++);
//var pr = LLVM.BuildPointerCast(Builder, return_buffer,
// LLVM.PointerType(LLVM.VoidType(), 0), "i" + instruction_id++);
args[0] = pt;
args[1] = pp;
@@ -288,6 +288,8 @@ public static string FindNativeCoreLib()
{
}
// Try something else...
try
{
// Let's try the calling executable directory.
@@ -303,6 +305,25 @@ public static string FindNativeCoreLib()
{
}
// Try something else...
try
{
// This could be a unit test in Campy. If that is true, then look in the standard directory structure
// for Campy source/object. It should have actually copied the damn corlib.dll to the output executable directory,
// but someone set up the test wrong. Anyways, assume that the project is up to date, and load from Campy.Runtime.
// ../../../../../Campy.Runtime/Corlib/bin/Debug/net20/
var path_of_campy = @"../../../../../Campy.Runtime/Corlib/bin/Debug/net20";
string full_path_assem = path_of_campy + Path.DirectorySeparatorChar + "corlib.dll";
full_path_assem = Path.GetFullPath(full_path_assem);
Stream stream = new FileStream(full_path_assem, FileMode.Open, FileAccess.Read, FileShare.Read);
stream.Close();
return full_path_assem;
}
catch (Exception e)
{
}
// Fuck. I have no idea.
return null;
}
@@ -192,8 +192,8 @@ public static void For(int number_of_threads, KernelType kernel)
}
finally
{
handle1.Free();
handle2.Free();
if (default(GCHandle) != handle1) handle1.Free();
if (default(GCHandle) != handle2) handle2.Free();
}
}

0 comments on commit fba9328

Please sign in to comment.