OpenCL bit-matrix multiplication (implementing tiling in local memory)
-
Hi Leon. Thanks for your input. To clarify, this is an assignment I am working on. The arrays were set by the instructor, believe it or not, and I am not allowed to modify them. My job is to setup OpenCL and write a kernel that correctly multiplies the two matrices. I know for a fact that my kernel works correctly because the instructor has provided a function that performs the same calculation on the CPU and then compares the two results. I have uploaded the VS15 project files at https://uploadfiles.io/
It isn't valid C++ code ... Are you seriously telling me you can compile these 3 lines of code on Visual Studio?
unsigned long long A = new unsigned long long[n*n/64]; // stores bits in 64-bit integers
unsigned long long B = new unsigned long long[n*n/64]; // for example, one row consists of 256 bits and uses 4x64-bit integers to store them
int C = new int[n*n];I don't care what n is I actually don't know a C++ compiler that will take that. Visual Studio 2017 will report it correctly that it's missing an all important "*" making it a pointer
Error (active) E0144 a value of type "unsigned long long *" cannot be used to initialize an entity of type "unsigned long long"
Error (active) E0144 a value of type "unsigned long long *" cannot be used to initialize an entity of type "unsigned long long"
Error (active) E0144 a value of type "int *" cannot be used to initialize an entity of type "int"Hence I am still favouring you have typed it wrong because you would be complaining of those errors and I can't believe a lecturer would write that. Your link isn't correct so I can't look at what I suspect is the real code. Are you allowed to change BitProduct function to
__kernel void BitProduct(const int N, const __global unsigned long long* A, const __global unsigned long long* B, __global int* C)
That might give you a fighting chance other than that I am pretty sure you are wasting your time and go talk to lecturer.
In vino veritas
-
It isn't valid C++ code ... Are you seriously telling me you can compile these 3 lines of code on Visual Studio?
unsigned long long A = new unsigned long long[n*n/64]; // stores bits in 64-bit integers
unsigned long long B = new unsigned long long[n*n/64]; // for example, one row consists of 256 bits and uses 4x64-bit integers to store them
int C = new int[n*n];I don't care what n is I actually don't know a C++ compiler that will take that. Visual Studio 2017 will report it correctly that it's missing an all important "*" making it a pointer
Error (active) E0144 a value of type "unsigned long long *" cannot be used to initialize an entity of type "unsigned long long"
Error (active) E0144 a value of type "unsigned long long *" cannot be used to initialize an entity of type "unsigned long long"
Error (active) E0144 a value of type "int *" cannot be used to initialize an entity of type "int"Hence I am still favouring you have typed it wrong because you would be complaining of those errors and I can't believe a lecturer would write that. Your link isn't correct so I can't look at what I suspect is the real code. Are you allowed to change BitProduct function to
__kernel void BitProduct(const int N, const __global unsigned long long* A, const __global unsigned long long* B, __global int* C)
That might give you a fighting chance other than that I am pretty sure you are wasting your time and go talk to lecturer.
In vino veritas
Oh ok. I see the mix up. I forgot to add the * in my original post. Of course I am initializing a pointer to dynamically allocated memory.
unsigned long long *A = new unsigned long long[n*n/64]; // stores bits in 64-bit integers
unsigned long long *B = new unsigned long long[n*n/64]; // for example, one row consists of 256 bits and uses 4x64-bit integers to store them
int C = new int[n*n]; -
Oh ok. I see the mix up. I forgot to add the * in my original post. Of course I am initializing a pointer to dynamically allocated memory.
unsigned long long *A = new unsigned long long[n*n/64]; // stores bits in 64-bit integers
unsigned long long *B = new unsigned long long[n*n/64]; // for example, one row consists of 256 bits and uses 4x64-bit integers to store them
int C = new int[n*n];Well, you should always copy/paste your original code snippets, not just type it here from scratch!
-
It isn't valid C++ code ... Are you seriously telling me you can compile these 3 lines of code on Visual Studio?
unsigned long long A = new unsigned long long[n*n/64]; // stores bits in 64-bit integers
unsigned long long B = new unsigned long long[n*n/64]; // for example, one row consists of 256 bits and uses 4x64-bit integers to store them
int C = new int[n*n];I don't care what n is I actually don't know a C++ compiler that will take that. Visual Studio 2017 will report it correctly that it's missing an all important "*" making it a pointer
Error (active) E0144 a value of type "unsigned long long *" cannot be used to initialize an entity of type "unsigned long long"
Error (active) E0144 a value of type "unsigned long long *" cannot be used to initialize an entity of type "unsigned long long"
Error (active) E0144 a value of type "int *" cannot be used to initialize an entity of type "int"Hence I am still favouring you have typed it wrong because you would be complaining of those errors and I can't believe a lecturer would write that. Your link isn't correct so I can't look at what I suspect is the real code. Are you allowed to change BitProduct function to
__kernel void BitProduct(const int N, const __global unsigned long long* A, const __global unsigned long long* B, __global int* C)
That might give you a fighting chance other than that I am pretty sure you are wasting your time and go talk to lecturer.
In vino veritas
-
Try this link Uploadfiles.io - bitMatrices.rar[^]
At least you now agree you have typo errors which I could only guess at, so we made some progress. Now can you to go carefully thru the code you typed because there are more errors which I have guessed at :-) Your code you have posted doesn't appear in the code you have linked so it's really confusing to me what it's relevance? The code you linked is throwing masses of warnings a couple of them will be fatal if they get called, is this your code or the lecturers? Lets give you a sample of one of the probably fatal warnings
printf("Program (%d):\n%s\n\n",err,program[p]);
The second parameter is listed as a string %s, what is passed in is a cl_program which is a struct AKA nothing like a string This is one of the problems with vardiac argument calls they are dangerous, the compiler can't be certain it's fatal but like me it's guessing it is may be fatal or at the least very bad and warning about it. So lets deal with how easy this could be fatal, well if the struct contains no zero's bytes printf is treating the struct as a string so it will keep reading past the struct itself and you are going to get a good old memory access fatal error. So can we start again, either refer directly to the code you linked or type proper valid code for your question. I don't mind helping but you have to give me proper valid code to look at.
In vino veritas
-
At least you now agree you have typo errors which I could only guess at, so we made some progress. Now can you to go carefully thru the code you typed because there are more errors which I have guessed at :-) Your code you have posted doesn't appear in the code you have linked so it's really confusing to me what it's relevance? The code you linked is throwing masses of warnings a couple of them will be fatal if they get called, is this your code or the lecturers? Lets give you a sample of one of the probably fatal warnings
printf("Program (%d):\n%s\n\n",err,program[p]);
The second parameter is listed as a string %s, what is passed in is a cl_program which is a struct AKA nothing like a string This is one of the problems with vardiac argument calls they are dangerous, the compiler can't be certain it's fatal but like me it's guessing it is may be fatal or at the least very bad and warning about it. So lets deal with how easy this could be fatal, well if the struct contains no zero's bytes printf is treating the struct as a string so it will keep reading past the struct itself and you are going to get a good old memory access fatal error. So can we start again, either refer directly to the code you linked or type proper valid code for your question. I don't mind helping but you have to give me proper valid code to look at.
In vino veritas
All of the warnings are due to the instructor's code. In fact, all of the source code files were provided by the instructor. My task was to modify one of the given functions (in order to setup and launch the kernel) and write the actual kernel. In spite of the many warnings, were you able to compile and run the code?
-
All of the warnings are due to the instructor's code. In fact, all of the source code files were provided by the instructor. My task was to modify one of the given functions (in order to setup and launch the kernel) and write the actual kernel. In spite of the many warnings, were you able to compile and run the code?
Nope it crashes and burns as you would expect given the warnings. I wasn't going to debug a whole pile of code which I assumed was your homework.
In vino veritas
-
Nope it crashes and burns as you would expect given the warnings. I wasn't going to debug a whole pile of code which I assumed was your homework.
In vino veritas
-
It is strange that you had to assume this was homework when I explicitly stated that it was on more than one occasion.
You said and I quote it exactly "To clarify, this is an assignment I am working on." "The arrays were set by the instructor, believe it or not, and I am not allowed to modify them." So are you telling me this isn't a homework assignment for a programming unit? University assignments are about you learning not someone on the network doing them for you. Secondly I am not allowed to correct somethings like the array creation obviously so how would I know what I can and can not correct? I feel confident any normal person would assume what I have and if it comes as a shock to you well sorry it is logical. We could go into how you reconcile those statements with it not being a homework assignment but lets just ignore that and move on. All I can say is the current code crashes and burns beautifully at the moment which is entirely predictable. So to even help at the moment I need to know what code I am allowed to change and what I can't which you clearly know but I have no clue. Do you at least see and agree I need to know what is allowed to be changed?
In vino veritas
-
You said and I quote it exactly "To clarify, this is an assignment I am working on." "The arrays were set by the instructor, believe it or not, and I am not allowed to modify them." So are you telling me this isn't a homework assignment for a programming unit? University assignments are about you learning not someone on the network doing them for you. Secondly I am not allowed to correct somethings like the array creation obviously so how would I know what I can and can not correct? I feel confident any normal person would assume what I have and if it comes as a shock to you well sorry it is logical. We could go into how you reconcile those statements with it not being a homework assignment but lets just ignore that and move on. All I can say is the current code crashes and burns beautifully at the moment which is entirely predictable. So to even help at the moment I need to know what code I am allowed to change and what I can't which you clearly know but I have no clue. Do you at least see and agree I need to know what is allowed to be changed?
In vino veritas
1. So what you are telling me is that you thought the term "assignment" DID NOT mean "homework"? My mentioning the instructor didn't help you form the conceptual link between the two terms? 2. I specified that I can make changes to specific portions of the code. It is common for instructors to provide sample code and ask for changes to specific segments. 3. When I encounter a problem that I can't overcome, should I simply give up or try my hand at whatever resources I have at my disposal, including online forums? Do you advocate that I simply give up and not learn at all? To clarify, I worked out how to do memory tiling in the kernel. Perhaps your unjustifiably obnoxious behaviour helped me solve this and for that I am grateful. Lastly, you made a big fuss about the memory allocation segment when you could have simply said "Ehm, did you forget the asterisk?". People like you make online forums absolutely TOXIC and you should be ashamed of yourself.
-
1. So what you are telling me is that you thought the term "assignment" DID NOT mean "homework"? My mentioning the instructor didn't help you form the conceptual link between the two terms? 2. I specified that I can make changes to specific portions of the code. It is common for instructors to provide sample code and ask for changes to specific segments. 3. When I encounter a problem that I can't overcome, should I simply give up or try my hand at whatever resources I have at my disposal, including online forums? Do you advocate that I simply give up and not learn at all? To clarify, I worked out how to do memory tiling in the kernel. Perhaps your unjustifiably obnoxious behaviour helped me solve this and for that I am grateful. Lastly, you made a big fuss about the memory allocation segment when you could have simply said "Ehm, did you forget the asterisk?". People like you make online forums absolutely TOXIC and you should be ashamed of yourself.
I am not going to make the situation worse but I would like you to go thru it as an exercise Your Point 1> I still have no idea what you are saying, I think you are objecting to me referring to assignment as homework is that the issue? Your Point 2> I understood your point but I have no idea what code belongs to your lecturer and which belongs to you? Your Point 3> No use online forums but remember we are not mind readers, things that may be obvious to you are not to us. You may care to review the conversation and consider I may not be clear exactly what you are trying to do. I also took the time to write code and give you my best guess at an answer which is hardly the actions of someone trying to be "unjustifiably obnoxious" and I took the time to answer each of your responses. You may care to review the sticky, points 5 & 11 are very pertinent HOW TO ASK A QUESTION - C / C++ / MFC Discussion Boards[^] I actually didn't and still don't know if it was just missing an asterix because there are multiple problems as none of the types matched up. It is the same as structs being rolled in as strings in variadic printf statements, it's hard to work out what was intended. This rolls back to point 5 on the HOW TO ASK A QUESTION sticky. I am sorry you feel I was being toxic that was definitely not my intent and if that belief spurred you to solve the problem at least that was a positive and hopefully you will be more careful with postings in future.
In vino veritas