Skip to content

Conversation

@TimmyLiu
Copy link

@TimmyLiu TimmyLiu commented Oct 9, 2015

No description provided.

TimmyLiu pushed a commit that referenced this pull request Oct 9, 2015
merge master branch to develop branch
@TimmyLiu TimmyLiu merged commit febcf41 into ROCm:develop Oct 9, 2015
wbgilmartin added a commit that referenced this pull request Oct 21, 2019
* integration of the new tensile client

* New tensile client (#1)

* Refactoring

* Move tensile_host.hpp from public C API to private C++ implementation

* Work around missing complex; fix formatting

* Remove --lib option and argument; make use of legacy handle API instead of introducing a new host handle API

* Map values to value categories currently represented as double

* minor changes

* merge Bill & Lee's changes

* Merge Bill & Lee's changes

* Fix build errors

* Merge 2.10 develop into new tensile client (#2)

* Changed timeout from hours to minutes (#699)

* set clang include directory, fix for centos build error

* hot fix to restore loading of DGEMM replacement kernels (#701)

* SLES support (#704)

* Merging master with SLES commit

* Specifying GPU architecture for ubuntu and sles (#695)

* Fixing Timeout

* BF16 replacement kernels (#705)

* hot fix to restore loading of DGEMM replacement kernels
* Revert "Switch to using separate D for gemm_ex benchmark calls (#667)"
This reverts commit 402d231.
* bf16 kernels for gfx908
* use bf16 UseBeta=0 replacement kernels
* update tensile_tag to use bf16 UseBeta=0 replacement kernels

* Restore usebeta1 logic (#707)

* restore UseBeta=1 logic for arcturus BF16 TN

* Supporting clang10 for SLES (#708)

* Batched syr (#727)

* adding syr batched and strided batched

* rocblas_stride, reusable template pattern work

* WIP

* fixes testing and format

* restore dependency

* adds minimal batches  & bad arg

* fix bad arg testing

* constify ptrs, spelling

* add alpha vector support, PR feedback

* more BF16 TN sizes

* Refactoring

* Move tensile_host.hpp from public C API to private C++ implementation

* Work around missing complex; fix formatting

* Remove --lib option and argument; make use of legacy handle API instead of introducing a new host handle API

* gf908 BF16 TN 512x512x512 known issue

* Enable SLES packaging (#719)

* Refactor Ger and Gemv (#735)

* Map values to value categories currently represented as double

* Rot(m)(g) batched and strided_batched (#737)

* SWDEV 203994 (#743)

* Refactor alpha, beta logging; do not return invalid pointer errors in GEMM, GEMV when other arguments allow early exit

* Fixes

* update

* version for master branch release

* version for develop branch release

* update Tensile package number

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests (#741)

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests

* Missing braces/spelling

* spelling

* Fixing packaging

* New Winograd kernels added (#742)

* fix for changes of FreeIndices change in Tensile

* New tensile client (#3)

* Changed timeout from hours to minutes (#699)

* set clang include directory, fix for centos build error

* hot fix to restore loading of DGEMM replacement kernels (#701)

* SLES support (#704)

* Merging master with SLES commit

* Specifying GPU architecture for ubuntu and sles (#695)

* Fixing Timeout

* BF16 replacement kernels (#705)

* hot fix to restore loading of DGEMM replacement kernels
* Revert "Switch to using separate D for gemm_ex benchmark calls (#667)"
This reverts commit 402d231.
* bf16 kernels for gfx908
* use bf16 UseBeta=0 replacement kernels
* update tensile_tag to use bf16 UseBeta=0 replacement kernels

* Restore usebeta1 logic (#707)

* restore UseBeta=1 logic for arcturus BF16 TN

* Supporting clang10 for SLES (#708)

* Batched syr (#727)

* adding syr batched and strided batched

* rocblas_stride, reusable template pattern work

* WIP

* fixes testing and format

* restore dependency

* adds minimal batches  & bad arg

* fix bad arg testing

* constify ptrs, spelling

* add alpha vector support, PR feedback

* more BF16 TN sizes

* Refactoring

* Move tensile_host.hpp from public C API to private C++ implementation

* Work around missing complex; fix formatting

* Remove --lib option and argument; make use of legacy handle API instead of introducing a new host handle API

* gf908 BF16 TN 512x512x512 known issue

* Enable SLES packaging (#719)

* Refactor Ger and Gemv (#735)

* Map values to value categories currently represented as double

* Rot(m)(g) batched and strided_batched (#737)

* SWDEV 203994 (#743)

* Refactor alpha, beta logging; do not return invalid pointer errors in GEMM, GEMV when other arguments allow early exit

* Fixes

* update

* version for master branch release

* version for develop branch release

* update Tensile package number

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests (#741)

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests

* Missing braces/spelling

* spelling

* Fixing packaging

* New Winograd kernels added (#742)

* Fix GEMM for half type

* updates to get rocblas-test and half sizes to work

* partial fix for NaN test failures

* New tensile client (#4)

* Changed timeout from hours to minutes (#699)

* set clang include directory, fix for centos build error

* hot fix to restore loading of DGEMM replacement kernels (#701)

* SLES support (#704)

* Merging master with SLES commit

* Specifying GPU architecture for ubuntu and sles (#695)

* Fixing Timeout

* BF16 replacement kernels (#705)

* hot fix to restore loading of DGEMM replacement kernels
* Revert "Switch to using separate D for gemm_ex benchmark calls (#667)"
This reverts commit 402d231.
* bf16 kernels for gfx908
* use bf16 UseBeta=0 replacement kernels
* update tensile_tag to use bf16 UseBeta=0 replacement kernels

* Restore usebeta1 logic (#707)

* restore UseBeta=1 logic for arcturus BF16 TN

* Supporting clang10 for SLES (#708)

* Batched syr (#727)

* adding syr batched and strided batched

* rocblas_stride, reusable template pattern work

* WIP

* fixes testing and format

* restore dependency

* adds minimal batches  & bad arg

* fix bad arg testing

* constify ptrs, spelling

* add alpha vector support, PR feedback

* more BF16 TN sizes

* Refactoring

* Move tensile_host.hpp from public C API to private C++ implementation

* Work around missing complex; fix formatting

* Remove --lib option and argument; make use of legacy handle API instead of introducing a new host handle API

* gf908 BF16 TN 512x512x512 known issue

* Enable SLES packaging (#719)

* Refactor Ger and Gemv (#735)

* Map values to value categories currently represented as double

* Rot(m)(g) batched and strided_batched (#737)

* SWDEV 203994 (#743)

* Refactor alpha, beta logging; do not return invalid pointer errors in GEMM, GEMV when other arguments allow early exit

* Fixes

* update

* version for master branch release

* version for develop branch release

* update Tensile package number

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests (#741)

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests

* Missing braces/spelling

* spelling

* Fixing packaging

* New Winograd kernels added (#742)

* Fix GEMM for half type

* Refactoring classes to be simpler

* Fix rocblas_half

* fix negative workgroup mapping error

* fix WorkGroupMapping issue for files in asm_lite

* more fixes for workgroupmapping issue

* wgm issue for asm_miopen

* New tensile client (#5)

* Changed timeout from hours to minutes (#699)

* set clang include directory, fix for centos build error

* hot fix to restore loading of DGEMM replacement kernels (#701)

* SLES support (#704)

* Merging master with SLES commit

* Specifying GPU architecture for ubuntu and sles (#695)

* Fixing Timeout

* BF16 replacement kernels (#705)

* hot fix to restore loading of DGEMM replacement kernels
* Revert "Switch to using separate D for gemm_ex benchmark calls (#667)"
This reverts commit 402d231.
* bf16 kernels for gfx908
* use bf16 UseBeta=0 replacement kernels
* update tensile_tag to use bf16 UseBeta=0 replacement kernels

* Restore usebeta1 logic (#707)

* restore UseBeta=1 logic for arcturus BF16 TN

* Supporting clang10 for SLES (#708)

* Batched syr (#727)

* adding syr batched and strided batched

* rocblas_stride, reusable template pattern work

* WIP

* fixes testing and format

* restore dependency

* adds minimal batches  & bad arg

* fix bad arg testing

* constify ptrs, spelling

* add alpha vector support, PR feedback

* more BF16 TN sizes

* Refactoring

* Move tensile_host.hpp from public C API to private C++ implementation

* Work around missing complex; fix formatting

* Remove --lib option and argument; make use of legacy handle API instead of introducing a new host handle API

* gf908 BF16 TN 512x512x512 known issue

* Enable SLES packaging (#719)

* Refactor Ger and Gemv (#735)

* Map values to value categories currently represented as double

* Rot(m)(g) batched and strided_batched (#737)

* SWDEV 203994 (#743)

* Refactor alpha, beta logging; do not return invalid pointer errors in GEMM, GEMV when other arguments allow early exit

* Fixes

* update

* version for master branch release

* version for develop branch release

* update Tensile package number

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests (#741)

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests

* Missing braces/spelling

* spelling

* Fixing packaging

* New Winograd kernels added (#742)

* Changing Gemv and Ger stride type (#747)

* Handle spaces and newline (#748)

* Fix GEMM for half type

* Tuned Shakespeare kernels (#749)

* Refactoring classes to be simpler

* Fix rocblas_half

* fix argument validation in gemm calls

* fix complex strided batch implementation

* fix validateArgs redefinition

* New tensile client (#6)

* Changed timeout from hours to minutes (#699)

* set clang include directory, fix for centos build error

* hot fix to restore loading of DGEMM replacement kernels (#701)

* SLES support (#704)

* Merging master with SLES commit

* Specifying GPU architecture for ubuntu and sles (#695)

* Fixing Timeout

* BF16 replacement kernels (#705)

* hot fix to restore loading of DGEMM replacement kernels
* Revert "Switch to using separate D for gemm_ex benchmark calls (#667)"
This reverts commit 402d231.
* bf16 kernels for gfx908
* use bf16 UseBeta=0 replacement kernels
* update tensile_tag to use bf16 UseBeta=0 replacement kernels

* Restore usebeta1 logic (#707)

* restore UseBeta=1 logic for arcturus BF16 TN

* Supporting clang10 for SLES (#708)

* Batched syr (#727)

* adding syr batched and strided batched

* rocblas_stride, reusable template pattern work

* WIP

* fixes testing and format

* restore dependency

* adds minimal batches  & bad arg

* fix bad arg testing

* constify ptrs, spelling

* add alpha vector support, PR feedback

* more BF16 TN sizes

* Refactoring

* Move tensile_host.hpp from public C API to private C++ implementation

* Work around missing complex; fix formatting

* Remove --lib option and argument; make use of legacy handle API instead of introducing a new host handle API

* gf908 BF16 TN 512x512x512 known issue

* Enable SLES packaging (#719)

* Refactor Ger and Gemv (#735)

* Map values to value categories currently represented as double

* Rot(m)(g) batched and strided_batched (#737)

* SWDEV 203994 (#743)

* Refactor alpha, beta logging; do not return invalid pointer errors in GEMM, GEMV when other arguments allow early exit

* Fixes

* update

* version for master branch release

* version for develop branch release

* update Tensile package number

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests (#741)

* Fixing SLES tests LD_LIBRARY_PATH and refactoring tests

* Missing braces/spelling

* spelling

* Fixing packaging

* New Winograd kernels added (#742)

* Changing Gemv and Ger stride type (#747)

* Handle spaces and newline (#748)

* Fix GEMM for half type

* Tuned Shakespeare kernels (#749)

* Refactoring classes to be simpler

* Fix rocblas_half

* Cleanup source
TorreZuk pushed a commit to TorreZuk/rocBLAS that referenced this pull request Dec 10, 2019
amcamd added a commit that referenced this pull request Apr 7, 2020
zaliu pushed a commit to zaliu/rocBLAS that referenced this pull request Apr 23, 2020
* Simplify TensileHost initialization
* cleanup path handling
mlse-lib-jenkins pushed a commit that referenced this pull request Oct 5, 2020
zaliu pushed a commit that referenced this pull request Oct 14, 2020
assistant-librarian bot pushed a commit that referenced this pull request Jan 9, 2026
[rocBLAS] Refactor memory management in host_alloc.cpp
 (#3672)

## Summary

Improved memory management in `host_alloc.cpp` by refactoring the
deallocation logic for better efficiency and adding diagnostic warnings
for untracked pointer frees.

## Changes

1. **Refactored `free_ptr_use()` to use iterator-based access** (reduces
redundant map lookups)
2. **Added warning for freeing untracked pointers** (helps detect
potential memory corruption issues)

## Motivation

The current implementation of `free_ptr_use()` in `host_alloc.cpp` had
two issues:

1. **Performance:** Redundant map lookups when deallocating tracked
memory
2. **Correctness:** Using `operator[]` on a map can unintentionally
insert entries for non-existent keys
3. **Diagnostics:** Silent failures when attempting to free untracked
pointers made debugging difficult

This PR addresses all three issues by refactoring the lookup logic and
adding diagnostic warnings.

## Technical Details

**File:** `projects/rocblas/clients/common/host_alloc.cpp`

### Change 1: Iterator-based memory deallocation

**Before:**
```cpp
if(ptr && mem_allocated[ptr]) {           // Lookup #1 (may insert!)
    mem_used -= mem_allocated[ptr];       // Lookup #2
    mem_allocated.erase(ptr);             // Lookup #3
}
```

**After:**
```cpp
auto it = mem_allocated.find(ptr);        // Single lookup
if(ptr && it != mem_allocated.end()) {
    mem_used -= it->second;               // Use cached iterator
    mem_allocated.erase(it);              // Use cached iterator
}
```

**Benefits:**
- Reduces map lookups from 3 to 1
- Prevents unintended map insertions via `operator[]`
- More efficient memory tracking

### Change 2: Diagnostic warning for untracked pointers

**Added:**
```cpp
else if(ptr && call_free)
{
    rocblas_cerr << "Warning: Freeing untracked pointer " << ptr
                 << " - untracked memory released (potential double-free or memory corruption)"
                 << std::endl;
}
```

**Benefits:**
- Helps detect double-free bugs
- Identifies potential memory corruption issues
- Provides actionable diagnostic information during testing

## Test Plan

- Built rocBLAS with no compilation errors
- Existing client test suite exercises memory allocation/deallocation
paths
- No functional behavior changes to normal operation
- Warning messages help identify issues during debugging

## Test Result

- All existing tests continue to pass
- Memory tracking functionality unchanged
- Warning properly triggers for untracked pointer frees
- No behavioral differences for correctly tracked memory

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants