Skip to content

Commit

Permalink
Initialize repo
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Jan 6, 2025
0 parents commit 5c7c06e
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
22 changes: 22 additions & 0 deletions .github/workflows/runic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Runic formatting
on:
push:
branches:
- 'master'
- 'release-'
tags:
- '*'
pull_request:
jobs:
runic:
name: Runic
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: julia-actions/cache@v2
- uses: fredrikekre/runic-action@v1
with:
version: '1'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Manifest.toml
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/fredrikekre/runic-pre-commit
rev: v1.0.0
hooks:
- id: runic
22 changes: 22 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The AMDuProf.jl package is licensed under the MIT "Expat" License:

> Copyright (c) 2025: Valentin Churavy.
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
>
10 changes: 10 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = "AMDuProf"
uuid = "daa9b3a6-8962-499d-9a2c-78f8dd591076"
authors = ["Valentin Churavy <[email protected]>"]
version = "0.1.0"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[compat]
Libdl = "1.10.0"
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# AMDuProf.jl

*Julia interface for the AMDuProf Application programming Interfaces*

## Collection control

When actually using AMDuProf tools to profile your application, it's recommended to start the
profiler in paused mode, and use AMDuPerf.jl to only instrument the parts of your code that
you are interested in. This can be done as follows:

```julia
using AMDuProf

# warm-up, compile code, etc

AMDuProf.resume()
# do interesting things here
AMDuProf.pause()

# convenience macro for the above:
AMDuProf.@collect begin
# ...
end
```

## Acknowledgments

- https://github.com/JuliaPerf/IntelITT.jl

42 changes: 42 additions & 0 deletions src/AMDuProf.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module AMDuProf

import Libdl

global libAMDProfileController::String = ""

function __init__()
global libAMDProfileController = Libdl.find_library("libAMDProfileController", ["/opt/amduprof/lib/x64/shared"])
return nothing
end

available() = !isempty(libAMDProfileController)

export pause, resume

function pause()
if !available()
return false
else
return @ccall libAMDProfileController.amdProfilePauseImpl()::Bool
end
end

function resume()
if !available()
return false
else
return @ccall libAMDProfileController.amdProfileResumeImpl()::Bool
end
end

macro collect(ex)
return quote
resume()
# Use Expr(:tryfinally, ...) so we don't introduce a new soft scope.
# TODO: switch to solution once https://github.com/JuliaLang/julia/pull/39217 is resolved
$(Expr(:tryfinally, esc(ex), :(pause())))
end
end


end # module AMDuProf
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using AMDuProf, Test

resume()
pause()
AMDuProf.@collect begin end

0 comments on commit 5c7c06e

Please sign in to comment.