This tutorial is for designing custom SST components to extend the "elements" library in a separate folder other than the SST root directory.

This will be useful in terms of version control using git, since you will not need to push existing elements to the git remote. Instead, you will be pushing only custom components built by you.

Choose any folder where you want to create a custom component. I am going to create it at ~/research/sst-components/simpleComponent.

Folder structure of this location will be as follows:

pratsriv@ccal03:~/research/sst-components/simpleComponent$ tree
.
├── compA.cc
├── compA.h
├── Makefile
└── tests
    └── simpleComponent.py

1 directory, 5 files

compA.h

#ifndef _compA_H
#define _compA_H

// Necessary when creating a custom component
#include <sst/core/component.h>

// Think of your component as a way to extend the existing SST library
namespace SST{
    
  // Adding all your variables in a namespace for the custom 
  // component library
  namespace simpleComponent{

    // component that you want to create needs to extend 
    // SST::Component class
    class compA : public SST::Component {

    public:

      // This function registers the custom component in the element
      // library (ELI) which can be checked after addition by 
      // sst-info <custom component library name>
      SST_ELI_REGISTER_COMPONENT(
          compA,                            // Component class
          "simpleComponent",                // Comp. lib. (for Python lookup)
          "compA",                          // Comp. name (for Python lookup)
          SST_ELI_ELEMENT_VERSION(1,0,0),   // Version of the component
          "Basic: dummy",                   // Description
          COMPONENT_CATEGORY_UNCATEGORIZED  // Category
      )

      // Documenting parmeters. This info shows up when using sst-info or 
      // when running a test using python
      SST_ELI_DOCUMENT_PARAMS(
          { "param1",     "Parameter 1",     "1" }
      )   

      // These functions are useless for this component since we don't have 
      // anything defined.
      SST_ELI_DOCUMENT_PORTS()
      SST_ELI_DOCUMENT_STATISTICS()
      SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS()

      // Constructor. Components receive a unique id and set of 
      // params from python
      compA(SST::ComponentId_t id, SST::Params& params);

      // Destructor
      ~compA();

    private:

      // Params
      std::string param1;

      // SST Output object. Will be used when printing variables/strings.
      SST::Output* out;

    };
  }
}

#endif

compA.cc

// Required header file for any sst custom library
#include <sst_config.h>
#include "compA.h"

using namespace SST;
using namespace SST::simpleComponent;

// Defining the constructor of the component (class) that you built.
// This component does the following:
// 1. Instantiate the "out" variable, which is used for printing
//    things
// 2. Registers the component as primary
// 3. Does not end the simulation until we're done
// 4. Initialize the parameter "param1" with a default value "blah"
// 5. Print a message with the parameter
// 6. Destroy the object
compA::compA(ComponentId_t id, Params& params) : Component(id) {
    out = new Output("", 1, 0, Output::STDOUT);

registerAsPrimaryComponent();
primaryComponentDoNotEndSim();

param1 = params.find<std::string>("param1", "blah");
out->output("Printing this message : %s\\n", param1.c_str());
}

compA::~compA() {
    delete out;
}

Makefile

CXX=$(shell sst-config --CXX)
CXXFLAGS=$(shell sst-config --ELEMENT_CXXFLAGS) $(shell sst-config --ELEMENT_CXXFLAGS)/sst/core/
LDFLAGS=$(shell sst-config --ELEMENT_LDFLAGS)

all: libsimpleComponent.so install

libsimpleComponent.so: compA.cc
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $<

install:
	sst-register simpleComponent simpleComponent_LIBDIR=$(CURDIR)
	sst-register SST_ELEMENT_SOURCE simpleComponent=$(CURDIR)
	sst-register SST_ELEMENT_TESTS  simpleComponent=$(CURDIR)/../tests

clean:
	rm -f *.o libsimpleComponent.so

simpleComponent.py

# Mandatory import 
import sst 

# Initialize a variable with the respective component
# compA = component name
# simpleComponent.compA = component-library.component-class
simpleComponent = sst.Component("compA", "simpleComponent.compA")

# Add parameter
# simpleComponent.addParams({
#     "param1" : "hello"
# })