Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the error by having manual casting the value to genetic when pass… #67

Merged
merged 2 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Src/ILGPU/Backends/OpenCL/CLCodeGenerator.Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ public void AppendArgumentAddress(Variable argument)
AppendCommand(CLInstructions.AddressOfOperation);
Append(argument);
}
/// <summary>
/// Appends the address of the given register argument with a cast.
/// </summary>
/// <param name="argument">The argument to append.</param>
/// <param name="typeExpression">Appends an unsafe cast expression</param>
public void AppendArgumentAddressWithCast(Variable argument, string typeExpression)
{
AppendArgument();
AppendCast(typeExpression);
AppendCommand(CLInstructions.AddressOfOperation);
Append(argument);
}

/// <summary>
/// Append ths given operation.
Expand Down
2 changes: 1 addition & 1 deletion Src/ILGPU/Backends/OpenCL/CLCodeGenerator.Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void Visit(AtomicCAS atomicCAS)
statement.BeginArguments();
statement.AppendAtomicCast(atomicCAS.ArithmeticBasicValueType);
statement.AppendArgument(target);
statement.AppendArgumentAddress(value);
statement.AppendArgumentAddressWithCast(value, $"{CLInstructions.GetAddressSpacePrefix(MemoryAddressSpace.Generic)} {CLTypeGenerator.GetBasicValueType(atomicCAS.ArithmeticBasicValueType)} {CLInstructions.DereferenceOperation}");
statement.AppendArgument(compare);
statement.EndArguments();
}
Expand Down
2 changes: 1 addition & 1 deletion Src/ILGPU/Backends/OpenCL/CLInstructions.Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ partial class CLInstructions

private static readonly string[] AddressSpacePrefixes =
{
string.Empty,
"__generic",
"global",
"local",
"private",
Expand Down