• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    Go
  • License
    Other
  • Created about 13 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dynamic object-oriented programming support for the Go language

Goop

Go Reference Go Report Card

Description

The Goop (Go Object-Oriented Programming) package provides support for dynamic object-oriented programming constructs in Go, much like those that appear in various scripting languages. The goal is to integrate fast, native-Go objects and slower but more flexible Goop objects within the same program.

Features

Goop provides the following features, which are borrowed from an assortment of object-oriented programming languages:

  • a prototype-based object model

  • support for both ex nihilo and constructor-based object creation

  • the ability to add, replace, and remove data fields and method functions at will

  • multiple inheritance

  • dynamically modifiable inheritance hierarchies (even on a per-object basis)

  • type-dependent dispatch (i.e., multiple methods with the same name but different argument types)

Installation

Goop is a Go module and therefore does not need to be installed manually. Simply import it as github.com/lanl/goop, and go build should download and install the code automatically.

Documentation

Pre-built documentation for the Goop API is available online at https://pkg.go.dev/github.com/lanl/goop.

Performance

Goop is unfortunately extremely slow. Goop programs have to pay for their flexibility in terms of performance. To determine just how bad the performance is on your computer, you can run the microbenchmarks included in goop_test.go:

    go test -bench=. -benchtime=5s github.com/lanl/goop

On my computer, I get results like the following (reformatted for clarity):

    BenchmarkNativeFNV1             2000000000                 4.59 ns/op
    BenchmarkNativeFNV1Closure      2000000000                 4.59 ns/op
    BenchmarkGoopFNV1                100000000                70.5  ns/op
    BenchmarkMoreGoopFNV1             10000000               794    ns/op
    BenchmarkEvenMoreGoopFNV1          5000000              2517    ns/op

See goop_test.go for the complete source code for those benchmarks. Basically,

  • BenchmarkNativeFNV1 is native (i.e., non-Goop) Go code for computing a 64-bit FNV-1 hash on a sequence of 0xFF bytes. Each iteration ("op" in the performance results) comprises a nullary function call, a multiplication by a large prime number, and an exclusive or with an 0xFF byte.

  • BenchmarkNativeFNV1Closure is the same but instead of calling an ordinary function each iteration, it invokes a locally defined closure.

  • BenchmarkGoopFNV1 defines a Goop object that contains a single data field (the current hash value) and no methods. Each iteration performs one Get and one Set on the Goop object.

  • BenchmarkMoreGoopFNV1 replaces the hash function with an object method. Hence, each iteration performs one Get, one Set, and one Call on the Goop object.

  • BenchmarkEvenMoreGoopFNV1 adds support for type-dependent dispatch to the hash-function method. Although only one type signature is defined, Goop has to confirm at run time that the provided arguments do in fact match that signature.

Another way to interpret the data shown above is that, on my computer at least, a function closure is essentially free; Get and Set cost approximately 33 ns apiece; a Call of a nullary function costs about 724 ns; and type-dependent dispatch costs an additional 1723 ns.

How does Goop compare to various scripting languages? Not well, at least for BenchmarkMoreGoopFNV1 and its equivalents in other languages. The following table shows the cost in nanoseconds of an individual BenchmarkMoreGoopFNV1 operation (a function call, a read of a data field, a 64-bit multiply, an 8-bit exclusive or, and a write to a data field):

Language Run time (ns/op)
[Incr Tcl] 8.6.0 24490
Go 1.3.1 + Goop 794
JavaScript 1.7 (Rhino 1.7R4-2) 682
Perl 5.18.2 622
Python 2.7.6 604
Python 3.4.0 567
Ruby 1.9.3.4 513
Python 2.7.3 + PyPy 206

In short, you'll want to do most of your coding in native Go and use Goop only when your application requires the extra flexibility that Goop provides. Then, you should cache as many object members as possible in Go variables to reduce the number of Get and Set calls.

Legal statement

Copyright © 2011, Triad National Security, LLC. All rights reserved.

This software was produced under U.S. Government contract 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of Energy/National Nuclear Security Administration. All rights in the program are reserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear Security Administration. The Government is granted for itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so. NEITHER THE GOVERNMENT NOR TRIAD NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to produce derivative works, such modified software should be clearly marked, so as not to confuse it with the version available from LANL.

Goop is provided under a BSD 3-clause license. See the LICENSE file for the full text.

Triad National Security, LLC (Triad) owns the copyright to Goop, a component of the LANL Go Suite (identified internally as LA-CC-11-056).

Author

Scott Pakin, [email protected]

More Repositories

1

qmasm

Quantum macro assembler for D-Wave systems
Python
332
star
2

pyxDamerauLevenshtein

pyxDamerauLevenshtein implements the Damerau-Levenshtein (DL) edit distance algorithm for Python in Cython for high performance.
Python
241
star
3

quantum_algorithms

Codes accompanying the paper "Quantum algorithm implementations for beginners"
Jupyter Notebook
188
star
4

vpic

Vector Particle-In-Cell (VPIC) Project
C++
151
star
5

yelpapi

yelpapi is a pure Python implementation of the Yelp Fusion API (aka Yelp v3 API).
Python
135
star
6

CoARCT

Code Analysis and Refactoring with Clang Tools
C++
122
star
7

LaGriT

Los Alamos Grid Toolbox (LaGriT) is a library of user callable tools that provide mesh generation, mesh optimization and dynamic mesh maintenance in two and three dimensions.
Fortran
122
star
8

scico

Scientific Computational Imaging COde
Python
92
star
9

MPI-Bash

Parallel version of the Bash shell
C
83
star
10

pyHarmonySearch

pyHarmonySearch is a pure Python implementation of the harmony search (HS) global optimization algorithm.
Python
81
star
11

dfnWorks

dfnWorks is a parallelized computational suite to generate three-dimensional discrete fracture networks (DFN) and simulate flow and transport. If you download the software please fill out our interest form to stay up to date on releases https://goo.gl/forms/VE39oKsyp4LVC6Gj2 and join our google group https://groups.google.com/d/forum/dfnworks-users . Precompiled Docker Container https://hub.docker.com/r/ees16/dfnworks
Python
74
star
12

CLAMR

Cell-Based Adaptive Mesh Refinement
C++
69
star
13

hippynn

python library for atomistic machine learning
Python
67
star
14

mcnptools

C++
66
star
15

parthenon

Parthenon AMR infrastructure
C++
65
star
16

OpenFWI

A collection of codes with OpenFWI project
Python
63
star
17

MF-LBM

MF-LBM: A Portable, Scalable and High-performance Lattice Boltzmann Code for DNS of Flow in Porous Media
Fortran
62
star
18

Byfl

Program analysis tool based on software performance counters
C++
56
star
19

FEHM

Finite Element Heat and Mass Transfer Code
GLSL
52
star
20

PPT

Performance Prediction Toolkit
Python
51
star
21

SNAP

SN Application Proxy
Fortran
48
star
22

vision_transformers_explained

This folder of code contains code and notebooks to supplement the "Vision Transformers Explained" series published on Towards Data Science written by Skylar Callis.
Jupyter Notebook
48
star
23

phoebus

Phifty One Ergs Blows Up A Star
Jupyter Notebook
44
star
24

vpic-kokkos

Kokkos port of VPIC
C++
43
star
25

clp

Go language bindings for the COIN-OR Linear Programming library
Go
43
star
26

LATTE

Developer repository for the LATTE code
Fortran
40
star
27

bml

The Basic Matrix Library (bml)
C
38
star
28

VPSC_code

Visco Plastic Self Consistent code
TeX
36
star
29

Architector

The architector python package - for 3D metal complex design. C22085
Python
35
star
30

PYSEQM

an interface to semi-empirical quantum chemistry methods implemented with pytorch
Python
34
star
31

adscodex

ADS Codex is a codec for organic molecular archives.
Go
34
star
32

Fierro

Fierro is a C++ code designed to aid the research and development of numerical methods, testing of user-specified models, and creating multi-scale models related to quasi-static solid mechanics and compressible material dynamics using low- and high-order meshes.
C++
32
star
33

ExactPack

ExactPack: An Open-Source Software Package for Code Verification
Python
31
star
34

Blackout-Diffusion

Jupyter Notebook
31
star
35

ALF

A framework for performing active learning for training machine-learned interatomic potentials.
Python
30
star
36

nubhlight

General Relativistic Neutrino Radiation Magnetohydrodynamics for Neutron Star Merger Disks
C
29
star
37

SEPIA

Simulation-Enabled Prediction, Inference, and Analysis: physics-informed statistical learning.
Python
29
star
38

QA-Prolog

Quantum Annealing Prolog
Go
27
star
39

APPFL

Auto-parallelizing Pure Functional Language
Haskell
27
star
40

SICM

Simplified Interface to Complex Memory
C
26
star
41

color

studies on color, colormaps, and colorspaces
R
25
star
42

singularity-eos

Performance portable equations of state and mixed cell closures
C++
25
star
43

CGMF

CGMF nuclear fission fragment de-excitation statistical code
Jupyter Notebook
25
star
44

PyBNF

An application for parameterization of biological models available in SBML and BNGL formats. Features include parallelization, metaheuristic optimization algorithms, and an adaptive Markov chain Monte Carlo (MCMC) sampling algorithm.
Python
25
star
45

circle

Go language interface to the Libcircle distributed-queue API
Go
24
star
46

PISTON

A Portable Cross-Platform Framework for Data-Parallel Visualization Operators
C++
24
star
47

MATAR

MATAR is a C++ software library to allow developers to easily create and use dense and sparse data representations that are also portable across disparate architectures using Kokkos.
C++
24
star
48

edif2qmasm

Run hardware descriptions on a quantum annealer
Go
21
star
49

PENNANT

Unstructured mesh hydrodynamics for advanced architectures
C++
21
star
50

libquo

Dynamic execution environments for coupled, thread-heterogeneous MPI+X applications
C
21
star
51

pyDNMFk

Python Distributed Non Negative Matrix Factorization with custom clustering
Python
20
star
52

qmd-progress

PROGRESS: Parallel, Rapid O(N) and Graph-based Recursive Electronic Structure Solver.
Fortran
20
star
53

ELEMENTS

The C++ ELEMENTS library contains a suite of sub-libraries to support mathematical functions (elements), data representations (MATAR), and novel mesh classes (geometry and SWAGE) to support a very broad range of element types, numerical methods, and mesh connectivity data structures useful for computational physics and engineering.
C++
20
star
54

pyBASS

Bayesian Adaptive Spline Surfaces for flexible and automatic regression
Python
19
star
55

ExascaleDocs

Exascale papers and presentations
Shell
19
star
56

FLPR

FLPR: The Fortran Language Program Remodeling system
C++
18
star
57

MILK

MAUD Interface Language Kit (MILK) is a set of Rietveld tools for automated processing of diffraction datasets.
Python
18
star
58

go-papi

Go language interface to the PAPI performance API
Go
18
star
59

VizAly-Foresight

A compression benchmark suite
C++
17
star
60

tycho2

A neutral particle transport mini-app to study performance of sweeps on unstructured, 3D tetrahedral meshes.
C++
17
star
61

Pavilion

HPC testing harness
Python
17
star
62

Zotero-Robust-Links-Extension

Create Robust Links from within Zotero
JavaScript
17
star
63

COVID-19-Predictions

Daily Forecasting of New Cases for Regional Epidemics of Coronavirus Disease 2019 with Bayesian Uncertainty Quantification
16
star
64

BEE

Python
15
star
65

jali

A parallel unstructured mesh framework for multiphysics application
C++
15
star
66

scout

Scout -- Domain Specific Language & Toolchain
C++
15
star
67

CODY

Continuum Dynamics Evaluation and Test Suite
C++
15
star
68

pyDNTNK

Python Distributed Non Negative Tensor Networks
Python
14
star
69

gridder

gridder is a simple interactive grid generation tool for creating 2D and 3D orthogonal grids. Used at Los Alamos National Laboratory (EES Group).
C
14
star
70

branson

A Monte Carlo transport mini-app for studying new parallel algorithms
C++
14
star
71

benchmarks

Benchmarks
C
14
star
72

CompactHash

A compact hash algorithm for CPUs and GPUs using OpenCL
C
14
star
73

Phase-Field-Dislocation-Dynamics-PFDD

Phase field model for material science applications.
C
14
star
74

PerfectHash

A perfect hash code for CPUs and GPUs using OpenCL
C
14
star
75

LAVA

Lava is a general-purpose calculator that provides a python interface to enable one-click calculation of the many common properties with LAMMPS and VASP. The name Lava is derived from the “La” in LAMMPS and “va” in VASP. It provides a set of classes and functions to generate configurations, run lammps/vasp calculation, retrieve the output, postprocess and plot the results. All the above tasks are hard-coded into the script, without the need to call additional libraries.
Python
14
star
76

McPhD

A Parallel Haskell framework for particle-based Monte Carlo simulations
Roff
13
star
77

NEXMD

Fortran
13
star
78

RAM-SCB

RAM-SCB is a unique code that combines a kinetic model of ring current plasma with a three dimensional force-balanced model of the terrestrial magnetic field to simulate Earth's inner magnetosphere.
Fortran
13
star
79

cosyr

A tool for coherent synchrotron radiation modeling
C++
12
star
80

EGG

Emulator Generation Gadget
C++
12
star
81

pyCP_APR

CP-APR Tensor Decomposition with PyTorch backend. pyCP_APR can perform non-negative Poisson Tensor Factorization on GPU, and includes an interface for anomaly detection using the extracted latent patterns.
Python
12
star
82

ares

Project ARES represents a joint effort between LANL and ORNL to introduce a common compiler representation and tool-chain for HPC applications. At the project's core is the High Level Intermediate Representation, or HLIR, for common compiler toolchains. HLIR is built ontop of the LLVM IR, using metadata to represent high-level parallel constructs.
C++
11
star
83

tinerator

Intuitive and powerful unstructured geospatial mesh generation from GIS data.
Python
10
star
84

CosmicEmu

Fast predictions for the matter power spectrum.
C
10
star
85

scico-data

Data for the scico project
Jupyter Notebook
10
star
86

pySimFrac

Python module for synthetic generation of rough fracture surfaces
Jupyter Notebook
9
star
87

minervachem

a python library for cheminformatics and machine learning
Python
9
star
88

c2dwave

Translate a subset of C to Verilog
C++
9
star
89

voronoi

Parallel Mesh Preprocessor for Subsurface Codes (LANL Copyright No. C19012)
Fortran
8
star
90

EOSlib

A C++ library, database, and utilities for performing thermodynamic calculations using analytic equations of state.
C
8
star
91

PyFEHM

Easy scripting environment for FEHM
Python
8
star
92

nuflood

An open-source software project for surface water simulation.
C++
8
star
93

TOGA

Tool for Optimization and Group-structure Analysis of nuclear multi-group cross sections
Python
8
star
94

stress-make

Expose race conditions in Makefiles
Go
8
star
95

JuliQAOA.jl

A fast, flexible package for simulating the Quantum Alternating Operator Ansatz
Julia
8
star
96

swiftbat_python

Utilities for BAT instrument on the Neil Gehrels Swift Observatory satellite
Python
8
star
97

bueno

A software framework for conducting well-provenanced computer system benchmarking
Python
8
star
98

singularity-opac

Performance portable routines for opacity, emissivity, and scattering
C++
8
star
99

CompactHashRemap

Fast mesh remapping algorithm based on hashing techniques
C
8
star
100

lca-pytorch

Sparse coding in PyTorch via the Locally Competitive Algorithm (LCA)
Python
7
star