Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new flags for THMapAllocator #757

Merged
merged 1 commit into from
Sep 6, 2016
Merged

Add new flags for THMapAllocator #757

merged 1 commit into from
Sep 6, 2016

Conversation

apaszke
Copy link
Contributor

@apaszke apaszke commented Sep 6, 2016

  • TH_ALLOCATOR_MAPPED_FROMFD uses an existing file descriptor for
    mapping (and steals it)
  • TH_ALLOCATOR_MAPPED_KEEPFD doesn't close the file descriptor
    until the mapping is freed
  • TH_ALLOCATOR_MAPPED_UNLINK unlinks the file immediately after
    mapping it to memory

Also, now it's using fstat to check the file size (instead of lseek, which alters the fd state).

* TH_ALLOCATOR_MAPPED_FROMFD uses an existing file descriptor for
  mapping (and steals it)
* TH_ALLOCATOR_MAPPED_KEEPFD doesn't close the file descriptor
  until the mapping is freed
* TH_ALLOCATOR_MAPPED_UNLINK unlinks the file immediately after
  mapping it to memory

Also, now it's using fstat to check the file size (instead of lseek,
which alters the fd state).
@soumith
Copy link
Member

soumith commented Sep 6, 2016

cc: @akfidjeland @timharley wrt the change from lseek to fstat. It's harmless, but want to keep you in the loop.

@timharley
Copy link
Contributor

Thanks @soumith

@soumith soumith merged commit 7bbe179 into torch:master Sep 6, 2016
@soumith
Copy link
Member

soumith commented Sep 6, 2016

Thanks @apaszke !

@tworec
Copy link

tworec commented Oct 21, 2016

I have problem with THAllocator.c line 262

In [1]:
s=torch.FloatStorage('/tmp/2rec', true, 10000)

gives me

unable to stretch file </tmp/2rec> to the right size at /home/tworec/torch/pkg/torch/lib/TH/THAllocator.c:262
stack traceback:
    [C]: at 0x7fd308444330
    [C]: in function 'FloatStorage'
    [string "s=torch.FloatStorage('/tmp/2rec', true, 10000..."]:1: in main chunk
    [C]: in function 'xpcall'
    /home/tworec/torch/install/share/lua/5.1/itorch/main.lua:210: in function </home/tworec/torch/install/share/lua/5.1/itorch/main.lua:174>
    /home/tworec/torch/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll'
    /home/tworec/torch/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll'
    /home/tworec/torch/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex'
    /home/tworec/torch/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start'
    /home/tworec/torch/install/share/lua/5.1/itorch/main.lua:389: in main chunk
    [C]: in function 'require'
    (command line):1: in main chunk
    [C]: at 0x00406670

@soumith
Copy link
Member

soumith commented Nov 8, 2016

@tworec this was fixed 13 days ago via #817

@tworec
Copy link

tworec commented Nov 8, 2016

yes, indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants