Skip to content

Commit

Permalink
connected up command line gce
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhack committed Apr 30, 2023
1 parent 772032e commit 2e81f11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 21 additions & 2 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package cmd

import (
"github.com/nathanhack/ecc/cmd/internal/create/gallager"
"github.com/nathanhack/ecc/cmd/internal/create/gce"
"github.com/nathanhack/ecc/cmd/internal/create/hamming"

"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -40,6 +42,15 @@ var createGallagerCmd = &cobra.Command{
Run: gallager.GallagerRun,
}

// createGCECmd represents the gce command
var createGCECmd = &cobra.Command{
Use: "gce OUTPUT_LDPC_JSON",
Short: "Creates a new GCE based ECC",
Long: `Creates a new GCE based ECC..`,
Args: cobra.ExactArgs(1),
Run: gce.GCERun,
}

// createHammingCmd represents the Hamming command
var createHammingCmd = &cobra.Command{
Use: "hamming OUTPUT_HAMMING_JSON",
Expand All @@ -54,8 +65,8 @@ func init() {
rootCmd.AddCommand(createCmd)
createCmd.AddCommand(createlinearblockCmd)
createlinearblockCmd.AddCommand(createldpcCmd)
createldpcCmd.AddCommand(createGallagerCmd)

createldpcCmd.AddCommand(createGallagerCmd)
createGallagerCmd.Flags().UintVarP(&gallager.Message, "message", "m", 1000, "the number of bits in the message")
createGallagerCmd.Flags().UintVarP(&gallager.Wc, "column", "c", 3, "the column weight (number of ones in the H matrix column) (>=3)")
createGallagerCmd.Flags().UintVarP(&gallager.Wr, "row", "r", 4, "the row weight (number of ones in the H matrix row) (column < row)")
Expand All @@ -64,8 +75,16 @@ func init() {
createGallagerCmd.Flags().UintVarP(&gallager.Threads, "threads", "t", 0, "the number of threads to use; note 0 means use the number of cpus")
createGallagerCmd.Flags().BoolVarP(&gallager.Verbose, "verbose", "v", false, "enable verbose info")

createlinearblockCmd.AddCommand(createHammingCmd)
createldpcCmd.AddCommand(createGCECmd)
createGCECmd.Flags().UintVarP(&gce.MessageSize, "message", "m", 1000, "the number of bits in the message")
createGCECmd.Flags().UintVarP(&gce.CodewordSize, "codeword", "c", 2000, "the number of bits for the whole codeword(message+ecc)")
createGCECmd.Flags().UintVarP(&gce.Girth, "girth", "g", 20, "the girth to use")
createGCECmd.Flags().UintVarP(&gce.Iter, "iter", "i", 10000, "the number of iterations to try before terminating the search")
createGCECmd.Flags().UintVarP(&gce.Threads, "threads", "t", 0, "the number of threads to use; note 0 means use the number of cpus")
createGCECmd.Flags().BoolVarP(&gce.Force, "force", "f", false, "to enable forcing")
createGCECmd.Flags().BoolVarP(&gce.Verbose, "verbose", "v", false, "enable verbose info")

createlinearblockCmd.AddCommand(createHammingCmd)
createHammingCmd.Flags().UintVarP(&hamming.ParityBits, "parity", "p", 4, "the parity >=2, sets codeword size (cs) == 2^parity-1 and message size == cs-parity")
createHammingCmd.Flags().UintVarP(&hamming.Threads, "threads", "t", 0, "the number of threads to use; note 0 means use the number of cpus")

Expand Down
5 changes: 5 additions & 0 deletions cmd/internal/create/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ var GCERun = func(cmd *cobra.Command, args []string) {
}

checkNodes := CodewordSize - MessageSize
if checkNodes <= 0 {
fmt.Println("required MessageSize > CodewordSize")
return
}

g, err := gce.Search(ctx, int(checkNodes), int(CodewordSize), int(Girth), int(Iter), int(Threads), Force, checkpoint)
if err != nil {
fmt.Println("Unable to create LDPC: ", err)
Expand Down

0 comments on commit 2e81f11

Please sign in to comment.