Jun 13, 2014 at 12:00 AM
Edited Jun 13, 2014 at 12:11 AM
I'm not sure whether it's just the way I've constructed my code, but I frequently make the mistake of Cudafying code that contains 2 copies of the one function.
This throw the generic dictionary error "an item with the same key has already been added", without telling me which function I am duplicating.
It would be very useful to have a more descriptive error in this case.
The code that needs editing is in CudafyTranslator -> CudafyTranlator.cs -> line 525 changing this:
cm.Functions.Add(med.Name, new KernelMethodInfo(type, mi, kmt, isDummy, behaviour, cm));
to something like this:
if(cm.Functions.ContainsKey(med.Name)) throw new ArgumentException("Function already defined: " + med.Name);
else cm.Functions.Add(med.Name, new KernelMethodInfo(type, mi, kmt, isDummy, behaviour, cm));// #######!!!
Even better would be adding info to the error message about where the 2 definitions are.
I'm happy to make the changes if you'd like, keeping in mind that I don't know how to check out the code properly and resubmit. Happy to learn though!