From 71f1161c5db73cbcec3419bdb4cfac93be0cfba1 Mon Sep 17 00:00:00 2001
From: John Romein <romein@astron.nl>
Date: Tue, 29 Apr 2025 15:16:57 +0200
Subject: [PATCH] Added backward-compatible tcc::Correlator() constructor.

---
 libtcc/Correlator.cc | 29 +++++++++++++++++++++++++++++
 libtcc/Correlator.h  | 10 ++++++++++
 2 files changed, 39 insertions(+)

diff --git a/libtcc/Correlator.cc b/libtcc/Correlator.cc
index 2fadd51..9d189d2 100644
--- a/libtcc/Correlator.cc
+++ b/libtcc/Correlator.cc
@@ -52,6 +52,35 @@ Correlator::Correlator(const cu::Device &device,
 }
 
 
+Correlator::Correlator(const cu::Device &device,
+		       unsigned nrBits,
+		       unsigned nrReceivers,
+		       unsigned nrChannels,
+		       unsigned nrSamplesPerChannel,
+		       unsigned nrPolarizations,
+		       unsigned nrReceiversPerBlock,
+		       const std::string &customStoreVisibility
+		      )
+:
+  Correlator(device, 
+	     [&] () -> Format {
+	       switch (nrBits) {
+		    case  4 : return Format::i4;
+		    case  8 : return Format::i8;
+		    case 16 : return Format::fp16;
+		    default : throw std::invalid_argument("nrBits should be 4, 8, or 16");
+	       }
+	     } (),
+	     nrReceivers,
+	     nrChannels,
+	     nrSamplesPerChannel,
+	     nrPolarizations,
+	     nrReceiversPerBlock,
+	     customStoreVisibility)
+{
+}
+
+
 unsigned Correlator::defaultNrReceiversPerBlock(unsigned nrReceivers) const
 {
   return nrReceivers <=  32 ? 32 :
diff --git a/libtcc/Correlator.h b/libtcc/Correlator.h
index ce93ae1..5f70534 100644
--- a/libtcc/Correlator.h
+++ b/libtcc/Correlator.h
@@ -23,6 +23,16 @@ namespace tcc {
 		 const std::string &customStoreVisibility = ""
 		); // throw (cu::Error, nvrtc::Error)
 
+      [[deprecated]] Correlator(const cu::Device &,
+		 unsigned nrBits,
+		 unsigned nrReceivers,
+		 unsigned nrChannels,
+		 unsigned nrSamplesPerChannel,
+		 unsigned nrPolarizations = 2,
+		 unsigned nrReceiversPerBlock = 0, // 0: use a heuristic value that should work well
+		 const std::string &customStoreVisibility = ""
+		); // throw (cu::Error, nvrtc::Error)
+
       void launchAsync(cu::Stream &, cu::DeviceMemory &visibilities, cu::DeviceMemory &samples, bool add = false); // throw (cu::Error)
       void launchAsync(CUstream, CUdeviceptr visibilities, CUdeviceptr samples, bool add = false); // throw (cu::Error)
 
-- 
GitLab