@@ -368,11 +368,21 @@ class CG {
368368 vector_class<detail::AccessorImplPtr> AccStorage,
369369 vector_class<shared_ptr_class<const void >> SharedPtrStorage,
370370 vector_class<Requirement *> Requirements,
371- vector_class<detail::EventImplPtr> Events)
371+ vector_class<detail::EventImplPtr> Events, detail::code_location loc = {} )
372372 : MType(Type), MArgsStorage(std::move(ArgsStorage)),
373373 MAccStorage (std::move(AccStorage)),
374374 MSharedPtrStorage(std::move(SharedPtrStorage)),
375- MRequirements(std::move(Requirements)), MEvents(std::move(Events)) {}
375+ MRequirements(std::move(Requirements)), MEvents(std::move(Events)) {
376+ // Capture the user code-location from Q.submit(), Q.parallel_for()
377+ // etc for later use; if code location information is not available,
378+ // the file name and function name members will be empty strings
379+ if (loc.functionName ())
380+ MFunctionName = loc.functionName ();
381+ if (loc.fileName ())
382+ MFileName = loc.fileName ();
383+ MLine = loc.lineNumber ();
384+ MColumn = loc.columnNumber ();
385+ }
376386
377387 CG (CG &&CommandGroup) = default;
378388
@@ -397,6 +407,12 @@ class CG {
397407 vector_class<Requirement *> MRequirements;
398408 // List of events that order the execution of this CG
399409 vector_class<detail::EventImplPtr> MEvents;
410+ // Member variables to capture the user code-location
411+ // information from Q.submit(), Q.parallel_for() etc
412+ // Storage for function name and source file name
413+ string_class MFunctionName, MFileName;
414+ // Storage for line and column of code location
415+ int32_t MLine, MColumn;
400416};
401417
402418// The class which represents "execute kernel" command group.
@@ -420,10 +436,10 @@ class CGExecKernel : public CG {
420436 vector_class<ArgDesc> Args, string_class KernelName,
421437 detail::OSModuleHandle OSModuleHandle,
422438 vector_class<shared_ptr_class<detail::stream_impl>> Streams,
423- CGTYPE Type)
439+ CGTYPE Type, detail::code_location loc = {} )
424440 : CG(Type, std::move(ArgsStorage), std::move(AccStorage),
425441 std::move (SharedPtrStorage), std::move(Requirements),
426- std::move(Events)),
442+ std::move(Events), std::move(loc) ),
427443 MNDRDesc(std::move(NDRDesc)), MHostKernel(std::move(HKernel)),
428444 MSyclKernel(std::move(SyclKernel)), MArgs(std::move(Args)),
429445 MKernelName(std::move(KernelName)), MOSModuleHandle(OSModuleHandle),
@@ -450,10 +466,11 @@ class CGCopy : public CG {
450466 vector_class<detail::AccessorImplPtr> AccStorage,
451467 vector_class<shared_ptr_class<const void >> SharedPtrStorage,
452468 vector_class<Requirement *> Requirements,
453- vector_class<detail::EventImplPtr> Events)
469+ vector_class<detail::EventImplPtr> Events,
470+ detail::code_location loc = {})
454471 : CG(CopyType, std::move(ArgsStorage), std::move(AccStorage),
455472 std::move (SharedPtrStorage), std::move(Requirements),
456- std::move(Events)),
473+ std::move(Events), std::move(loc) ),
457474 MSrc(Src), MDst(Dst) {}
458475 void *getSrc () { return MSrc; }
459476 void *getDst () { return MDst; }
@@ -470,10 +487,11 @@ class CGFill : public CG {
470487 vector_class<detail::AccessorImplPtr> AccStorage,
471488 vector_class<shared_ptr_class<const void >> SharedPtrStorage,
472489 vector_class<Requirement *> Requirements,
473- vector_class<detail::EventImplPtr> Events)
490+ vector_class<detail::EventImplPtr> Events,
491+ detail::code_location loc = {})
474492 : CG(FILL, std::move(ArgsStorage), std::move(AccStorage),
475493 std::move (SharedPtrStorage), std::move(Requirements),
476- std::move(Events)),
494+ std::move(Events), std::move(loc) ),
477495 MPattern(std::move(Pattern)), MPtr((Requirement *)Ptr) {}
478496 Requirement *getReqToFill () { return MPtr; }
479497};
@@ -487,10 +505,11 @@ class CGUpdateHost : public CG {
487505 vector_class<detail::AccessorImplPtr> AccStorage,
488506 vector_class<shared_ptr_class<const void >> SharedPtrStorage,
489507 vector_class<Requirement *> Requirements,
490- vector_class<detail::EventImplPtr> Events)
508+ vector_class<detail::EventImplPtr> Events,
509+ detail::code_location loc = {})
491510 : CG(UPDATE_HOST, std::move(ArgsStorage), std::move(AccStorage),
492511 std::move (SharedPtrStorage), std::move(Requirements),
493- std::move(Events)),
512+ std::move(Events), std::move(loc) ),
494513 MPtr((Requirement *)Ptr) {}
495514
496515 Requirement *getReqToUpdate () { return MPtr; }
@@ -508,10 +527,11 @@ class CGCopyUSM : public CG {
508527 vector_class<detail::AccessorImplPtr> AccStorage,
509528 vector_class<shared_ptr_class<const void >> SharedPtrStorage,
510529 vector_class<Requirement *> Requirements,
511- vector_class<detail::EventImplPtr> Events)
530+ vector_class<detail::EventImplPtr> Events,
531+ detail::code_location loc = {})
512532 : CG(COPY_USM, std::move(ArgsStorage), std::move(AccStorage),
513533 std::move (SharedPtrStorage), std::move(Requirements),
514- std::move(Events)),
534+ std::move(Events), std::move(loc) ),
515535 MSrc(Src), MDst(Dst), MLength(Length) {}
516536
517537 void *getSrc () { return MSrc; }
@@ -531,10 +551,11 @@ class CGFillUSM : public CG {
531551 vector_class<detail::AccessorImplPtr> AccStorage,
532552 vector_class<shared_ptr_class<const void >> SharedPtrStorage,
533553 vector_class<Requirement *> Requirements,
534- vector_class<detail::EventImplPtr> Events)
554+ vector_class<detail::EventImplPtr> Events,
555+ detail::code_location loc = {})
535556 : CG(FILL_USM, std::move(ArgsStorage), std::move(AccStorage),
536557 std::move (SharedPtrStorage), std::move(Requirements),
537- std::move(Events)),
558+ std::move(Events), std::move(loc) ),
538559 MPattern(std::move(Pattern)), MDst(DstPtr), MLength(Length) {}
539560 void *getDst () { return MDst; }
540561 size_t getLength () { return MLength; }
@@ -552,10 +573,11 @@ class CGPrefetchUSM : public CG {
552573 vector_class<detail::AccessorImplPtr> AccStorage,
553574 vector_class<shared_ptr_class<const void >> SharedPtrStorage,
554575 vector_class<Requirement *> Requirements,
555- vector_class<detail::EventImplPtr> Events)
576+ vector_class<detail::EventImplPtr> Events,
577+ detail::code_location loc = {})
556578 : CG(PREFETCH_USM, std::move(ArgsStorage), std::move(AccStorage),
557579 std::move (SharedPtrStorage), std::move(Requirements),
558- std::move(Events)),
580+ std::move(Events), std::move(loc) ),
559581 MDst(DstPtr), MLength(Length) {}
560582 void *getDst () { return MDst; }
561583 size_t getLength () { return MLength; }
@@ -570,10 +592,11 @@ class CGInteropTask : public CG {
570592 std::vector<detail::AccessorImplPtr> AccStorage,
571593 std::vector<std::shared_ptr<const void >> SharedPtrStorage,
572594 std::vector<Requirement *> Requirements,
573- std::vector<detail::EventImplPtr> Events, CGTYPE Type)
595+ std::vector<detail::EventImplPtr> Events, CGTYPE Type,
596+ detail::code_location loc = {})
574597 : CG(Type, std::move(ArgsStorage), std::move(AccStorage),
575598 std::move (SharedPtrStorage), std::move(Requirements),
576- std::move(Events)),
599+ std::move(Events), std::move(loc) ),
577600 MInteropTask(std::move(InteropTask)) {}
578601};
579602
0 commit comments