ATLAS Offline Software
Loading...
Searching...
No Matches
triton::backend::traccc Namespace Reference

Classes

class  ModelInstanceState
class  ModelState
class  TracccTritonInitializer
 Owns the embedded Athena application that backs the Traccc Triton backend, plus the process-wide device infrastructure it brings up. More...
class  TracccTritonRunner
 Drives the device reconstruction chain for a single Triton request. More...

Functions

TRITONSERVER_Error * TRITONBACKEND_Initialize (TRITONBACKEND_Backend *backend)
TRITONSERVER_Error * TRITONBACKEND_Finalize (TRITONBACKEND_Backend *backend)
TRITONSERVER_Error * TRITONBACKEND_ModelInitialize (TRITONBACKEND_Model *model)
TRITONSERVER_Error * TRITONBACKEND_ModelFinalize (TRITONBACKEND_Model *model)
TRITONSERVER_Error * TRITONBACKEND_ModelInstanceInitialize (TRITONBACKEND_ModelInstance *instance)
TRITONSERVER_Error * TRITONBACKEND_ModelInstanceFinalize (TRITONBACKEND_ModelInstance *instance)
TRITONSERVER_Error * TRITONBACKEND_ModelInstanceExecute (TRITONBACKEND_ModelInstance *instance, TRITONBACKEND_Request **requests, const uint32_t request_count)

Variables

const std::string iovInputName = "EVENT_IOV"
constexpr std::size_t iovSize = 5
const std::array< std::string, 4 > outputNames

Function Documentation

◆ TRITONBACKEND_Finalize()

TRITONSERVER_Error * triton::backend::traccc::TRITONBACKEND_Finalize ( TRITONBACKEND_Backend * backend)

Definition at line 150 of file TracccTritonBackend.cxx.

151{
152 // Delete the "global" state associated with the backend.
153 void* vstate;
154 RETURN_IF_ERROR(TRITONBACKEND_BackendState(backend, &vstate));
155 std::string* state = reinterpret_cast<std::string*>(vstate);
156
157 LOG_MESSAGE(
158 TRITONSERVER_LOG_INFO,
159 (std::string("TRITONBACKEND_Finalize: state is '") + *state + "'")
160 .c_str());
161
162 delete state;
163
164 return nullptr; // success
165}

◆ TRITONBACKEND_Initialize()

TRITONSERVER_Error * triton::backend::traccc::TRITONBACKEND_Initialize ( TRITONBACKEND_Backend * backend)

Definition at line 83 of file TracccTritonBackend.cxx.

84{
85 const char* cname;
86 RETURN_IF_ERROR(TRITONBACKEND_BackendName(backend, &cname));
87 std::string name(cname);
88
89 LOG_MESSAGE(
90 TRITONSERVER_LOG_INFO,
91 (std::string("TRITONBACKEND_Initialize: ") + name).c_str());
92
93 // Check the backend API version that Triton supports vs. what this
94 // backend was compiled against. Make sure that the Triton major
95 // version is the same and the minor version is >= what this backend
96 // uses.
97 uint32_t api_version_major, api_version_minor;
98 RETURN_IF_ERROR(
99 TRITONBACKEND_ApiVersion(&api_version_major, &api_version_minor));
100
101 LOG_MESSAGE(
102 TRITONSERVER_LOG_INFO,
103 (std::string("Triton TRITONBACKEND API version: ") +
104 std::to_string(api_version_major) + "." +
105 std::to_string(api_version_minor))
106 .c_str());
107 LOG_MESSAGE(
108 TRITONSERVER_LOG_INFO,
109 (std::string("'") + name + "' TRITONBACKEND API version: " +
110 std::to_string(TRITONBACKEND_API_VERSION_MAJOR) + "." +
111 std::to_string(TRITONBACKEND_API_VERSION_MINOR))
112 .c_str());
113
114 if ((api_version_major != TRITONBACKEND_API_VERSION_MAJOR) ||
115 (api_version_minor < TRITONBACKEND_API_VERSION_MINOR)) {
116 return TRITONSERVER_ErrorNew(
117 TRITONSERVER_ERROR_UNSUPPORTED,
118 "triton backend API version does not support this backend");
119 }
120
121 // The backend configuration may contain information needed by the
122 // backend, such as tritonserver command-line arguments. This
123 // backend doesn't use any such configuration but for this example
124 // print whatever is available.
125 TRITONSERVER_Message* backend_config_message;
126 RETURN_IF_ERROR(
127 TRITONBACKEND_BackendConfig(backend, &backend_config_message));
128
129 const char* buffer;
130 size_t byte_size;
131 RETURN_IF_ERROR(TRITONSERVER_MessageSerializeToJson(
132 backend_config_message, &buffer, &byte_size));
133 LOG_MESSAGE(
134 TRITONSERVER_LOG_INFO,
135 (std::string("backend configuration:\n") + buffer).c_str());
136
137 // This backend does not require any "global" state but as an
138 // example create a string to demonstrate.
139 std::string* state = new std::string("backend state");
140 RETURN_IF_ERROR(
141 TRITONBACKEND_BackendSetState(backend, reinterpret_cast<void*>(state)));
142
143 return nullptr; // success
144}

◆ TRITONBACKEND_ModelFinalize()

TRITONSERVER_Error * triton::backend::traccc::TRITONBACKEND_ModelFinalize ( TRITONBACKEND_Model * model)

Definition at line 395 of file TracccTritonBackend.cxx.

396{
397 void* vstate;
398 RETURN_IF_ERROR(TRITONBACKEND_ModelState(model, &vstate));
399 ModelState* model_state = reinterpret_cast<ModelState*>(vstate);
400 delete model_state;
401
402 return nullptr; // success
403}

◆ TRITONBACKEND_ModelInitialize()

TRITONSERVER_Error * triton::backend::traccc::TRITONBACKEND_ModelInitialize ( TRITONBACKEND_Model * model)

Definition at line 375 of file TracccTritonBackend.cxx.

376{
377 // Create a ModelState object and associate it with the
378 // TRITONBACKEND_Model. If anything goes wrong with initialization
379 // of the model state then an error is returned and Triton will fail
380 // to load the model.
381 ModelState* model_state;
382 RETURN_IF_ERROR(ModelState::Create(model, &model_state));
383 RETURN_IF_ERROR(
384 TRITONBACKEND_ModelSetState(model, reinterpret_cast<void*>(model_state)));
385
386 return nullptr; // success
387}
static TRITONSERVER_Error * Create(TRITONBACKEND_Model *triton_model, ModelState **state)

◆ TRITONBACKEND_ModelInstanceExecute()

TRITONSERVER_Error * triton::backend::traccc::TRITONBACKEND_ModelInstanceExecute ( TRITONBACKEND_ModelInstance * instance,
TRITONBACKEND_Request ** requests,
const uint32_t request_count )

Definition at line 557 of file TracccTritonBackend.cxx.

560{
561 // Collect various timestamps during the execution of this batch or
562 // requests. These values are reported below before returning from
563 // the function.
564
565 uint64_t exec_start_ns = 0;
566 SET_TIMESTAMP(exec_start_ns);
567
568 // Triton will not call this function simultaneously for the same
569 // 'instance'. But since this backend could be used by multiple
570 // instances from multiple models the implementation needs to handle
571 // multiple calls to this function at the same time (with different
572 // 'instance' objects). Best practice for a high-performance
573 // implementation is to avoid introducing mutex/lock and instead use
574 // only function-local and model-instance-specific state.
575 ModelInstanceState* instance_state;
576 RETURN_IF_ERROR(TRITONBACKEND_ModelInstanceState(
577 instance, reinterpret_cast<void**>(&instance_state)));
578 ModelState* model_state = instance_state->StateForModel();
579
580 // Set the CUDA device for this thread
581 // Seems that this is necessary to set the device for each request
582 // Without leads to out-of-bounds memory access error
583 cudaError_t err = cudaSetDevice(instance_state->DeviceId());
584 if (err != cudaSuccess)
585 {
586 return TRITONSERVER_ErrorNew(
587 TRITONSERVER_ERROR_INTERNAL,
588 ("Failed to set CUDA device: " + std::string(cudaGetErrorString(err))).c_str());
589 }
590
591 // 'responses' is initialized as a parallel array to 'requests',
592 // with one TRITONBACKEND_Response object for each
593 // TRITONBACKEND_Request object. If something goes wrong while
594 // creating these response objects, the backend simply returns an
595 // error from TRITONBACKEND_ModelInstanceExecute, indicating to
596 // Triton that this backend did not create or send any responses and
597 // so it is up to Triton to create and send an appropriate error
598 // response for each request. RETURN_IF_ERROR is one of several
599 // useful macros for error handling that can be found in
600 // backend_common.h.
601
602 std::vector<TRITONBACKEND_Response*> responses;
603 responses.reserve(request_count);
604 for (uint32_t r = 0; r < request_count; ++r) {
605 TRITONBACKEND_Request* request = requests[r];
606 TRITONBACKEND_Response* response;
607 RETURN_IF_ERROR(TRITONBACKEND_ResponseNew(&response, request));
608 responses.push_back(response);
609 }
610
611 // At this point, the backend takes ownership of 'requests', which
612 // means that it is responsible for sending a response for every
613 // request. From here, even if something goes wrong in processing,
614 // the backend must return 'nullptr' from this function to indicate
615 // success. Any errors and failures must be communicated via the
616 // response objects.
617 //
618 // To simplify error handling, the backend utilities manage
619 // 'responses' in a specific way and it is recommended that backends
620 // follow this same pattern. When an error is detected in the
621 // processing of a request, an appropriate error response is sent
622 // and the corresponding TRITONBACKEND_Response object within
623 // 'responses' is set to nullptr to indicate that the
624 // request/response has already been handled and no further processing
625 // should be performed for that request. Even if all responses fail,
626 // the backend still allows execution to flow to the end of the
627 // function so that statistics are correctly reported by the calls
628 // to TRITONBACKEND_ModelInstanceReportStatistics and
629 // TRITONBACKEND_ModelInstanceReportBatchStatistics.
630 // RESPOND_AND_SET_NULL_IF_ERROR, and
631 // RESPOND_ALL_AND_SET_NULL_IF_ERROR are macros from
632 // backend_common.h that assist in this management of response
633 // objects.
634
635 // The backend could iterate over the 'requests' and process each
636 // one separately. But for performance reasons it is usually
637 // preferred to create batched input tensors that are processed
638 // simultaneously. This is especially true for devices like GPUs
639 // that are capable of exploiting the large amount parallelism
640 // exposed by larger data sets.
641 //
642 // The backend utilities provide a "collector" to facilitate this
643 // batching process. The 'collector's ProcessTensor function will
644 // combine a tensor's value from each request in the batch into a
645 // single contiguous buffer. The buffer can be provided by the
646 // backend or 'collector' can create and manage it. In this backend,
647 // there is not a specific buffer into which the batch should be
648 // created, so use ProcessTensor arguments that cause collector to
649 // manage it. ProcessTensor does NOT support TRITONSERVER_TYPE_BYTES
650 // data type.
651
652 // BackendInputCollector::ProcessTensor leaves its TRITONBACKEND_Input
653 // handle uninitialized when TRITONBACKEND_RequestInput fails, and then
654 // dereferences it anyway -- one request that does not carry the input
655 // would take the whole server down. Check every request up front and skip
656 // the collector entirely unless they all have it, so such a request comes
657 // back as a normal error response.
658 bool all_inputs_present = true;
659 for (uint32_t r = 0; r < request_count; ++r) {
660 for (const std::string& name :
661 {model_state->InputCellsTensorName(), iovInputName}) {
662 TRITONBACKEND_Input* input = nullptr;
663 TRITONSERVER_Error* input_err =
664 TRITONBACKEND_RequestInput(requests[r], name.c_str(), &input);
665 if (input_err != nullptr) {
666 all_inputs_present = false;
667 RESPOND_AND_SET_NULL_IF_ERROR(&responses[r], input_err);
668 break;
669 }
670 }
671 }
672
673 BackendInputCollector collector(
674 requests, request_count, &responses, model_state->TritonMemoryManager(),
675 false /* pinned_enabled */, nullptr /* stream*/);
676
677 // To instruct ProcessTensor to "gather" the entire batch of input
678 // tensors into a single contiguous buffer in CPU memory, set the
679 // "allowed input types" to be the CPU ones (see tritonserver.h in
680 // the triton-inference-server/core repo for allowed memory types).
681 std::vector<std::pair<TRITONSERVER_MemoryType, int64_t>> allowed_input_types =
682 {{TRITONSERVER_MEMORY_CPU_PINNED, 0}, {TRITONSERVER_MEMORY_CPU, 0}};
683
684 const char *input_cells_buffer = nullptr;
685 size_t input_cells_buffer_byte_size = 0;
686 TRITONSERVER_MemoryType input_cells_buffer_memory_type;
687 int64_t input_cells_buffer_memory_type_id;
688
689 const char *input_iov_buffer = nullptr;
690 size_t input_iov_buffer_byte_size = 0;
691 TRITONSERVER_MemoryType input_iov_buffer_memory_type;
692 int64_t input_iov_buffer_memory_type_id;
693
694 if (all_inputs_present)
695 {
696 RESPOND_ALL_AND_SET_NULL_IF_ERROR(
697 responses, request_count,
698 collector.ProcessTensor(
699 model_state->InputCellsTensorName().c_str(), nullptr /* existing_buffer */,
700 0 /* existing_buffer_byte_size */, allowed_input_types, &input_cells_buffer,
701 &input_cells_buffer_byte_size, &input_cells_buffer_memory_type,
702 &input_cells_buffer_memory_type_id));
703 RESPOND_ALL_AND_SET_NULL_IF_ERROR(
704 responses, request_count,
705 collector.ProcessTensor(
706 iovInputName.c_str(), nullptr /* existing_buffer */,
707 0 /* existing_buffer_byte_size */, allowed_input_types, &input_iov_buffer,
708 &input_iov_buffer_byte_size, &input_iov_buffer_memory_type,
709 &input_iov_buffer_memory_type_id));
710
711 // Finalize the collector. If 'true' is returned, 'input_buffer'
712 // will not be valid until the backend synchronizes the CUDA
713 // stream or event that was used when creating the collector. For
714 // this backend, GPU is not supported and so no CUDA sync should
715 // be needed; so if 'true' is returned simply log an error.
716 const bool need_cuda_input_sync = collector.Finalize();
717 if (need_cuda_input_sync)
718 {
719 LOG_MESSAGE(
720 TRITONSERVER_LOG_ERROR,
721 "'Traccc' backend: unexpected CUDA sync required by collector");
722 }
723 }
724
725 bool print_stats = true;
726
727 // run the reco chain: deserialize CELLS, drive the device algorithms
728 // (clusterization -> spacepoint formation -> seeding -> track parameter
729 // estimation -> track finding) and copy the fitted tracks and their
730 // measurements back to the host. All of that lives in TracccTritonRunner.
731 uint64_t compute_start_ns = 0;
732 SET_TIMESTAMP(compute_start_ns);
733
734 TracccTritonRunner::Output traccc_result;
735 bool run_succeeded = false;
736 try
737 {
738 if (!all_inputs_present) {
739 throw std::runtime_error(
740 "request is missing the '" +
741 model_state->InputCellsTensorName() + "' or '" +
742 iovInputName + "' input tensor");
743 }
744 // max_batch_size is 0, so there is one request and one IOV
745 std::array<int64_t, iovSize> iov;
746 if (input_iov_buffer_byte_size != sizeof(iov)) {
747 throw std::runtime_error("'" + iovInputName + "' has the wrong size");
748 }
749 std::memcpy(iov.data(), input_iov_buffer, sizeof(iov));
750 using number_type = EventIDBase::number_type;
751 const EventIDBase eventID(
752 static_cast<number_type>(iov[0]), EventIDBase::UNDEFEVT,
753 static_cast<number_type>(iov[2]), static_cast<number_type>(iov[3]),
754 static_cast<number_type>(iov[1]));
755 instance_state->traccc_triton_runner_->run(
756 reinterpret_cast<const uint8_t*>(input_cells_buffer),
757 input_cells_buffer_byte_size, eventID,
758 static_cast<number_type>(iov[4]), print_stats, traccc_result);
759 run_succeeded = true;
760 }
761 catch (const std::exception& e)
762 {
763 RESPOND_ALL_AND_SET_NULL_IF_ERROR(
764 responses, request_count,
765 TRITONSERVER_ErrorNew(TRITONSERVER_ERROR_INTERNAL, e.what()));
766 }
767
768 uint64_t compute_end_ns = 0;
769 SET_TIMESTAMP(compute_end_ns);
770
771 bool supports_first_dim_batching;
772 RESPOND_ALL_AND_SET_NULL_IF_ERROR(
773 responses, request_count,
774 model_state->SupportsFirstDimBatching(&supports_first_dim_batching));
775
776 // Because the output tensor values are concatenated into a single
777 // contiguous 'output_buffer', the backend must "scatter" them out
778 // to the individual response output tensors. The backend utilities
779 // provide a "responder" to facilitate this scattering process.
780 // BackendOutputResponder does NOT support TRITONSERVER_TYPE_BYTES
781 // data type.
782
783 // Initialize the responder
784 BackendOutputResponder responder(
785 requests, request_count, &responses, model_state->TritonMemoryManager(),
786 supports_first_dim_batching, false /* pinned_enabled */,
787 nullptr /* stream*/);
788
789 auto output_proc_start = std::chrono::high_resolution_clock::now();
790
791 // Serialized output tensors
792 std::vector<std::vector<std::uint8_t>> output_bytes;
793 output_bytes.reserve(outputNames.size());
794
795 // Process the outputs. Skipped when the chain threw: every response has
796 // already been failed above and there is no result to unpack.
797 if (run_succeeded)
798 {
799 // Unlike BackendInputCollector::ProcessTensor, the responder's
800 // ProcessTensor returns void: errors are recorded directly into the
801 // per-request response objects rather than returned.
802 const auto sendCollection = [&](const std::string& name,
803 const auto& collection) {
804 std::vector<std::uint8_t>& bytes = output_bytes.emplace_back();
805 TracccTriton::serialize(collection, bytes);
806 std::vector<int64_t> shape = {
807 static_cast<int64_t>(bytes.size())};
808 responder.ProcessTensor(
809 name.c_str(), TRITONSERVER_TYPE_UINT8, shape,
810 reinterpret_cast<const char*>(bytes.data()),
811 TRITONSERVER_MEMORY_CPU, 0);
812 };
813 sendCollection("MEASUREMENTS", traccc_result.measurements);
814 sendCollection("CLUSTERS", traccc_result.clusters);
815 sendCollection("TRACKS", traccc_result.tracks.tracks);
816 sendCollection("TRACK_STATES", traccc_result.tracks.states);
817 }
818
819 if (print_stats)
820 {
821 auto output_proc_end = std::chrono::high_resolution_clock::now();
822 std::cout << "[TIMING] Output processing: "
823 << std::chrono::duration_cast<std::chrono::milliseconds>(
824 output_proc_end - output_proc_start).count()
825 << " ms" << std::endl;
826 }
827
828 // Finalize the responder. If 'true' is returned, the output
829 // tensors' data will not be valid until the backend synchronizes
830 // the CUDA stream or event that was used when creating the
831 // responder. For this backend, GPU is not supported and so no CUDA
832 // sync should be needed; so if 'true' is returned simply log an
833 // error.
834 const bool need_cuda_output_sync = responder.Finalize();
835 if (need_cuda_output_sync) {
836 LOG_MESSAGE(
837 TRITONSERVER_LOG_ERROR,
838 "'traccc' backend: unexpected CUDA sync required by responder");
839 }
840
841 // Send all the responses that haven't already been sent because of
842 // an earlier error.
843 for (auto& response : responses) {
844 if (response != nullptr) {
845 LOG_IF_ERROR(
846 TRITONBACKEND_ResponseSend(
847 response, TRITONSERVER_RESPONSE_COMPLETE_FINAL, nullptr),
848 "failed to send response");
849 }
850 }
851
852 uint64_t exec_end_ns = 0;
853 SET_TIMESTAMP(exec_end_ns);
854
855#ifdef TRITON_ENABLE_STATS
856 // For batch statistics need to know the total batch size of the
857 // requests. This is not necessarily just the number of requests,
858 // because if the model supports batching then any request can be a
859 // batched request itself.
860 size_t total_batch_size = 0;
861 if (!supports_first_dim_batching) {
862 total_batch_size = request_count;
863 } else {
864 for (uint32_t r = 0; r < request_count; ++r)
865 {
866 auto& request = requests[r];
867 TRITONBACKEND_Input* input = nullptr;
868 LOG_IF_ERROR(
869 TRITONBACKEND_RequestInputByIndex(request, 0 /* index */, &input),
870 "failed getting request input");
871 if (input != nullptr)
872 {
873 const int64_t* shape = nullptr;
874 LOG_IF_ERROR(
875 TRITONBACKEND_InputProperties(
876 input, nullptr, nullptr, &shape, nullptr, nullptr, nullptr),
877 "failed getting input properties");
878 if (shape != nullptr)
879 {
880 total_batch_size += shape[0];
881 }
882 }
883 }
884 }
885#else
886 (void)exec_start_ns;
887 (void)exec_end_ns;
888 (void)compute_start_ns;
889 (void)compute_end_ns;
890#endif // TRITON_ENABLE_STATS
891
892// Report statistics for each request, and then release the request.
893for (uint32_t r = 0; r < request_count; ++r)
894{
895 auto& request = requests[r];
896
897 #ifdef TRITON_ENABLE_STATS
898 LOG_IF_ERROR(
899 TRITONBACKEND_ModelInstanceReportStatistics(
900 instance_state->TritonModelInstance(), request,
901 (responses[r] != nullptr) /* success */, exec_start_ns,
902 compute_start_ns, compute_end_ns, exec_end_ns),
903 "failed reporting request statistics");
904 #endif // TRITON_ENABLE_STATS
905
906 LOG_IF_ERROR(
907 TRITONBACKEND_RequestRelease(request, TRITONSERVER_REQUEST_RELEASE_ALL),
908 "failed releasing request");
909}
910
911#ifdef TRITON_ENABLE_STATS
912 // Report batch statistics.
913 LOG_IF_ERROR(
914 TRITONBACKEND_ModelInstanceReportBatchStatistics(
915 instance_state->TritonModelInstance(), total_batch_size,
916 exec_start_ns, compute_start_ns, compute_end_ns, exec_end_ns),
917 "failed reporting batch request statistics");
918#endif // TRITON_ENABLE_STATS
919
920return nullptr; // success
921}
MDT_Response response
std::map< std::string, double > instance
std::unique_ptr< TracccTritonRunner > traccc_triton_runner_
const std::string & InputCellsTensorName() const
int r
Definition globals.cxx:22
unsigned int number_type
void serialize(const vecmem::edm::host< vecmem::edm::schema< VARTYPES... >, INTERFACE > &container, std::vector< std::uint8_t > &out)
Append container to out in the format described above.
const std::array< std::string, 4 > outputNames
The host-resident reconstruction result of one request: the track container, the measurements its sta...

◆ TRITONBACKEND_ModelInstanceFinalize()

TRITONSERVER_Error * triton::backend::traccc::TRITONBACKEND_ModelInstanceFinalize ( TRITONBACKEND_ModelInstance * instance)

Definition at line 534 of file TracccTritonBackend.cxx.

535{
536 void* vstate;
537 RETURN_IF_ERROR(TRITONBACKEND_ModelInstanceState(instance, &vstate));
538 ModelInstanceState* instance_state =
539 reinterpret_cast<ModelInstanceState*>(vstate);
540 delete instance_state;
541
542 return nullptr; // success
543}

◆ TRITONBACKEND_ModelInstanceInitialize()

TRITONSERVER_Error * triton::backend::traccc::TRITONBACKEND_ModelInstanceInitialize ( TRITONBACKEND_ModelInstance * instance)

Definition at line 471 of file TracccTritonBackend.cxx.

472{
473 // Get the model state associated with this instance's model.
474 TRITONBACKEND_Model* model;
475 RETURN_IF_ERROR(TRITONBACKEND_ModelInstanceModel(instance, &model));
476
477 void* vmodelstate;
478 RETURN_IF_ERROR(TRITONBACKEND_ModelState(model, &vmodelstate));
479 ModelState* model_state = reinterpret_cast<ModelState*>(vmodelstate);
480
481 // Create a ModelInstanceState object and associate it with the
482 // TRITONBACKEND_ModelInstance.
483 ModelInstanceState* instance_state;
484 RETURN_IF_ERROR(
485 ModelInstanceState::Create(model_state, instance, &instance_state));
486 RETURN_IF_ERROR(TRITONBACKEND_ModelInstanceSetState(
487 instance, reinterpret_cast<void*>(instance_state)));
488
489 // Set the CUDA device for this thread
490 cudaError_t err = cudaSetDevice(instance_state->DeviceId());
491 if (err != cudaSuccess)
492 {
493 return TRITONSERVER_ErrorNew(
494 TRITONSERVER_ERROR_INTERNAL,
495 ("Failed to set CUDA device: " + std::string(cudaGetErrorString(err))).c_str());
496 }
497
498 // Bring up the embedded Athena application (process-wide singleton,
499 // idempotent) and construct the per-instance runner that drives the
500 // device chain.
501 try
502 {
503 TracccTritonInitializer::Config config;
504 config.deviceId = instance_state->DeviceId();
505 config.nSlots = model_state->TotalInstanceCount();
506
508
509 const size_t slot = TracccTritonInitializer::instance().acquireSlot();
510 instance_state->traccc_triton_runner_ =
511 std::make_unique<TracccTritonRunner>(
513
514 LOG_MESSAGE(TRITONSERVER_LOG_INFO,
515 (std::string("'traccc' backend: instance '") +
516 instance_state->Name() + "' bound to event slot " +
517 std::to_string(slot)).c_str());
518 }
519 catch (const std::exception& e)
520 {
521 return TRITONSERVER_ErrorNew(
522 TRITONSERVER_ERROR_INTERNAL,
523 (std::string("Failed to initialize Traccc device chain: ") +
524 e.what()).c_str());
525 }
526 return nullptr; // success
527}
static TRITONSERVER_Error * Create(ModelState *model_state, TRITONBACKEND_ModelInstance *triton_model_instance, ModelInstanceState **state)
static TracccTritonInitializer & instance()
Get the process-wide singleton.
std::size_t acquireSlot()
Claim the next free event-store slot for a Triton model instance.
void initialize(const Config &config)
Boot the embedded Athena application and resolve all cached handles.

Variable Documentation

◆ iovInputName

const std::string triton::backend::traccc::iovInputName = "EVENT_IOV"

Definition at line 66 of file TracccTritonBackend.cxx.

◆ iovSize

std::size_t triton::backend::traccc::iovSize = 5
constexpr

Definition at line 67 of file TracccTritonBackend.cxx.

◆ outputNames

const std::array<std::string, 4> triton::backend::traccc::outputNames
Initial value:
= {
"MEASUREMENTS", "CLUSTERS", "TRACKS", "TRACK_STATES"}

Definition at line 69 of file TracccTritonBackend.cxx.

69 {
70 "MEASUREMENTS", "CLUSTERS", "TRACKS", "TRACK_STATES"};