-
Notifications
You must be signed in to change notification settings - Fork 546
Dev override ptxplus #70
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
base: dev
Are you sure you want to change the base?
Conversation
@@ -1453,7 +1454,7 @@ void extract_code_using_cuobjdump(){ | |||
|
|||
//! Read file into char* | |||
//TODO: convert this to C++ streams, will be way cleaner | |||
char* readfile (const std::string filename){ | |||
std::unique_ptr<char[]> readfile (const std::string filename){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for removing the char*?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a memory leak in the calling code. The choices were to either use the auto-freeing unique_ptr or to add a free to the calling code. It's a coding convention question if it's desired that the code should should malloc/free or if it should use the "modern" C++ features.
Also it looks like I had commented that there was some "malloc" mixed with "delete" or "new" mixed with "free. This is against the C++ standard, but probably works with most standard libraries.
const char *override_ptx_name = getenv("PTX_SIM_KERNELFILE"); | ||
if (override_ptx_name == NULL or getenv("PTX_SIM_USE_PTX_FILE") == NULL) { | ||
ptxcode = readfile(ptx->getPTXfilename()); | ||
} else { | ||
printf("GPGPU-Sim PTX: overriding embedded ptx with '%s' (PTX_SIM_USE_PTX_FILE is set)\n", override_ptx_name); | ||
ptxcode = readfile(override_ptx_name); | ||
} | ||
if(context->get_device()->get_gpgpu()->get_config().convert_to_ptxplus() ) { | ||
const char *override_ptxplus_name = getenv("PTXPLUS_SIM_KERNELFILE"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need another variable for this - we should probably just use the PTX_SIM_KERNELFILE variable and not override even if "context->get_device()->get_gpgpu()->get_config().convert_to_ptxplus()". Basically just change the "if(context->get_device()->get_gpgpu()->get_config().convert_to_ptxplus() ) {" at line 1729 to "else if"
This adds a new environment variable, PTXPLUS_SIM_KERNELFILE , which can be used to override the PTXPLUS file used in the simulation. This is useful, for example, when doing register reallocation. Currently the code still uses the ptxinfo from the original PTX output to determine the number of registers, etc, that are needed. It doesn't seem like there are any functions to determine the register count from the ptxplus (and ptxas can't read ptxplus).
This fixes some bugs with respect to using "delete" to free memory which was malloced. It also fixes some memory leaks of PTX.