mirror of
				https://github.com/NVIDIA/cuda-samples.git
				synced 2025-11-04 07:27:49 +08:00 
			
		
		
		
	memMapIpc: Resolve build-time warnings and minor potential issues (#329)
* Fix compute performance calculation type casting in gpuGetMaxGflopsDeviceIdDRV() for #109 * 3_CUDA_Features/memMapIPCDrv: Increase procIdx buffer size to prevent potential buffer overflow * memMapIPCDrv: Fix memory leaks and improve header inclusion - Remove redundant string.h header - Add memory cleanup for dynamically allocated JIT options and log buffer - Fix printf format specifier for unsigned long long
This commit is contained in:
		
							parent
							
								
									61bd39800d
								
							
						
					
					
						commit
						940a4c7a91
					
				@ -31,7 +31,6 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <cstring>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include "cuda.h"
 | 
			
		||||
@ -293,6 +292,11 @@ static void memMapGetDeviceFunction(char **argv) {
 | 
			
		||||
                                       jitNumOptions, jitOptions,
 | 
			
		||||
                                       (void **)jitOptVals));
 | 
			
		||||
    printf("> PTX JIT log:\n%s\n", jitLogBuffer);
 | 
			
		||||
 | 
			
		||||
    // Clean up dynamically allocated memory
 | 
			
		||||
    delete[] jitOptions;
 | 
			
		||||
    delete[] jitOptVals;
 | 
			
		||||
    delete[] jitLogBuffer;
 | 
			
		||||
  } else {
 | 
			
		||||
    checkCudaErrors(cuModuleLoad(&cuModule, module_path.c_str()));
 | 
			
		||||
  }
 | 
			
		||||
@ -379,7 +383,7 @@ static void childProcess(int devId, int id, char **argv) {
 | 
			
		||||
    // deterministic.
 | 
			
		||||
    barrierWait(&shm->barrier, &shm->sense, (unsigned int)procCount);
 | 
			
		||||
    if (id == 0) {
 | 
			
		||||
      printf("Step %lld done\n", (unsigned long long)i);
 | 
			
		||||
      printf("Step %llu done\n", (unsigned long long)i);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -550,7 +554,7 @@ static void parentProcess(char *app) {
 | 
			
		||||
  // Launch the child processes!
 | 
			
		||||
  for (i = 0; i < nprocesses; i++) {
 | 
			
		||||
    char devIdx[10];
 | 
			
		||||
    char procIdx[10];
 | 
			
		||||
    char procIdx[12];
 | 
			
		||||
    char *const args[] = {app, devIdx, procIdx, NULL};
 | 
			
		||||
    Process process;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user