Permalink
Browse files

Updated to work with PAPI 4.2.1 and the new go tool.

  • Loading branch information...
1 parent 6e3ba9d commit d761a6af47cf75a3a8f0bce77a82828acc28590e @spakin spakin committed Feb 22, 2012
Showing with 55 additions and 37 deletions.
  1. +33 −13 Makefile
  2. +21 −20 README.md
  3. +1 −1 papi-low.go
  4. +0 −3 papi_test.go
View
@@ -1,33 +1,53 @@
# Build the PAPI Go package.
# By Scott Pakin <pakin@lanl.gov>
-include $(GOROOT)/src/Make.inc
+VERSION=1.1
-VERSION=1.0
+FULLPKG=github.com/losalamos/go-papi
-TARG=papi
-
-CGOFILES=\
+DISTFILES=\
papi.go\
papi-high.go\
papi-low.go\
papi-mh.go\
+ consts2code\
+ Makefile\
+ papi_test.go\
+ papi_hl_test.go\
+ papi_ll_test.go\
+
+BUILTFILES=\
papi-errno.go\
papi-event.go\
- papi-emod.go\
+ papi-emod.go
-DISTFILES=\
+SOURCES=\
+ $(BUILTFILES)\
papi.go\
papi-high.go\
papi-low.go\
papi-mh.go\
- consts2code\
- Makefile\
- papi_test.go\
- papi_hl_test.go\
- papi_ll_test.go\
-include $(GOROOT)/src/Make.pkg
+# ---------------------------------------------------------------------------
+
+# Use the go tool to do most of the work.
+
+all: $(SOURCES)
+ go build $(FULLPKG)
+
+clean:
+ go clean $(FULLPKG)
+
+distclean: clean
+ $(RM) $(BUILTFILES)
+
+check test: all
+ go test -v $(FULLPKG)
+
+install: all
+ go install $(FULLPKG)
+
+.PHONY: all clean distclean check test install
# ---------------------------------------------------------------------------
View
@@ -22,35 +22,36 @@ reported.
Installation
------------
-If necessary, set the `GOROOT` environment variable to the directory
-containing `src/Make.inc` and `src/Make.pkg` and the `PAPI_INCDIR`
-environment variable to the directory containing `papi.h`. Also,
-ensure that the directory containing `libpapi.so` is listed in your
-`LD_LIBRARY_PATH`.
+Installation is a bit of a pain, as the new
+[`go`](http://weekly.golang.org/cmd/go/) tool doesn't yet handle
+custom `Makefile`s such as the one `go-papi` requires. (This
+requirement is due to some of `go-papi`'s source files being generated
+automatically by a Perl script.)
-Afterwards, you can follow the usual Go package installation
-procedure:
+First, download `go-papi` into your Go build tree without
+automatically building/installing it:
<pre>
- git clone http://github.com/losalamos/go-papi $GOROOT/src/pkg/github.com/losalamos/go-papi
- cd $GOROOT/src/pkg/github.com/losalamos/go-papi
- gomake
- gotest
- gomake install
+ go get -d -v github.com/losalamos/go-papi
</pre>
-It is then safe to do a `gomake clean`.
+Set the `PAPI_INCDIR` environment variable to the directory containing
+`papi.h`. Also, ensure that the directory containing `libpapi.so` is
+listed in your `LD_LIBRARY_PATH`.
-At the time of this writing,
-[`goinstall`](http://golang.org/cmd/goinstall/) is unable to install
-packages such as go-papi that require
-[`cgo`](http://golang.org/cmd/cgo/). If this is ever fixed, the
-preceding steps can be simplified into
+Next, switch to the `go-papi` directory and build/test/install the
+package:
<pre>
- goinstall github.com/losalamos/go-papi
+ cd $GOROOT/src/pkg/github.com/losalamos/go-papi
+ make
+ make check
+ make install
</pre>
+It is then safe to do a `make clean` to remove all of the byproducts
+of the installation process.
+
Documentation
-------------
@@ -68,7 +69,7 @@ Once you install go-papi, you can view the complete go-papi API with
[`godoc`](http://golang.org/cmd/godoc/), for example by running
<pre>
- godoc -http=:6060
+ godoc -http=:6060 -index
</pre>
to start a local Web server then viewing the documentation at
View
@@ -340,7 +340,7 @@ func EnumEvents(emask EventMask, modifier EventModifier) (matches []Event, err e
for errno = Errno(C.PAPI_enum_event(&c_event, C.int(ENUM_FIRST))); errno == papi_ok; errno = Errno(C.PAPI_enum_event(&c_event, c_mod)) {
matches = append(matches, Event(c_event))
}
- if errno != ENOEVNT {
+ if errno != ENOEVNT && errno != ESBSTR {
matches = nil
err = errno
return
View
@@ -10,7 +10,6 @@ import "testing"
// Prevent SomeValue from being optimized away by exporting it.
var SomeValue float64 = 123.456
-
// Peform a given number of floating-point operations, just to burn cycle.
func performWork(numFlops int) {
for i := 0; i < numFlops; i++ {
@@ -21,7 +20,6 @@ func performWork(numFlops int) {
}
}
-
// Ensure that we can map back-and-forth between event names and event codes.
func TestEventNames(t *testing.T) {
eventCodes := []Event{
@@ -47,7 +45,6 @@ func TestEventNames(t *testing.T) {
}
}
-
// Ensure that we can map event modifiers to strings.
func TestEventModifiers(t *testing.T) {
// papi.go makes some assumptions about a couple of PAPI's

0 comments on commit d761a6a

Please sign in to comment.