Intel® oneAPI Base Toolkit
Support for the core tools and libraries within the base toolkit that are used to build and deploy high-performance data-centric applications.
419 Discussions

scif_register() fails with Bad Address for mmap()-ed region

Andreas3
Beginner
1,435 Views

 

I do not know if this is the correct place to ask this question since KNC and KNL porducts are discontinued.

 

So, I am trying to access some physical addresses by mmap()-ing the /dev/mem file.

However scif_register() fails with Bad address.

 

As required by the API (http://registrationcenter.intel.com/irc_nas/4633/scif_userguide.pdf) 

addr, offset and len parameters to scif_register() are multiples of 4KiB.

 

Does anyone have a clue on why scif_register() fails for mmap()-ed regions?

 

 

    scif_epd_t epd = scif_open();
    if (epd == SCIF_OPEN_FAILED) {
        perror("scif_open(): cannot create a new endpoint");
        return false;
    }
 
    uint16_t port = 2;
    size_t len = getpagesize();
    int prot_flags = SCIF_PROT_READ | SCIF_PROT_WRITE;
    int map_flags = SCIF_MAP_FIXED;

    int flags = O_RDWR;
    flags |= O_SYNC;
    int fd = open("/dev/mem", flags);
    if (fd < 0) {
        perror("ERROR: Failed to open /dev/mem");
        exit(-1);
    }

    // Truncate offset to a multiple of the page size, or mmap will fail.
    size_t page_base = (phys_addr / getpagesize()) * getpagesize();
    if (page_base != phys_addr) {
        fprintf(stderr, "ERROR: The given physical address is not a multiple of the page size.");
        exit(-1);
    }

    void *virt_addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, fd, page_base);
    if (virt_addr == MAP_FAILED) {
        perror("ERROR: Failed to mmap /dev/mem");
        exit(-1);
    }

    int port_given = scif_bind(epd, port);
    if (port_given < 0) {
        perror("scif_bind() failed");
        return false;
    }

    struct scif_portID *dst = (struct scif_portID *) malloc(sizeof(struct scif_portID));
    dst->node = conf->remote_peer_;
    dst->port = 1;

    int port_id = scif_connect(epd, dst);
    if (port_id < 0) {
        perror("scif_connect() failed");
        return false;
    }

    // addr and len are constrained to be multiples of the page size.
    off_t offset = scif_register(epd, virt_addr, len, 0, prot_flags, map_flags);
    if (offset == SCIF_REGISTER_FAILED) {
        perror("scif_register() failed");
        return false;
    }

 

 

 

 

0 Kudos
5 Replies
ShanmukhS_Intel
Moderator
1,331 Views

Hi,


Thanks for reaching out to us.


We would like to inform you that this forum supports oneAPI issues and oneAPI is not supported on KNC and KNL.


Below is the system requirement link for your reference.

https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-base-toolkit-system-requirements.html


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
1,180 Views

Hi,

 

Reminder:

Could you please let us know whether we have answered your query? Could you please confirm whether we could close this thread from our end?

 

Best Regards,

Shanmukh.SS

 

0 Kudos
Andreas3
Beginner
1,171 Views

Hi,

 

Unfortunately not.

 

Best regards,

Andreas

0 Kudos
ShanmukhS_Intel
Moderator
1,146 Views

Hi,


We would like to inform you that oneAPI is not supported on KNL and KNC. Hence we will not be able to provide any support on this case further. Please raise a new thread if you run into a problem with oneAPI on the supported platform. We will be happy to assist you on that.


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
1,121 Views

Hi,

 

We will close this inquiry now. If you need further assistance, please post a new question.

 

Best Regards,

Shanmukh.SS

 

0 Kudos
Reply